The right way to do it is to define what you allow, rather than to define what you don't. Anything that doesn't match what's allowed is rejected.
For example,
- only letters/numbers/internal hyphen,
- a single period with a minimum number of letters before/after
- Length of chars before and after the period should be sane (I don't know what the actual length limit for a domain is - I'm sure it's in an RFC).
- etc.
Anything that doesn't match this criteria should be rejected. I'm not saying this is the exact criteria to use in this case, but the theory is that you don't want to "strip out the bad" - rather define what is good and if it doesn't match, sayonara.
I couldn't find anywhere where python defines a domain name type object you could use - but perhaps there is a module out there.