Snippets

email

http://gist.github.com/47987 Check if an email address exists without sending an email.

String

Replace multiple spaces with a single space

Compressing consecutive spaces:

>>> test = "a  b c d   efdd  slkj   sdfdsfl"
>>> " ".join(test.split())
'a b c d efdd slkj sdfdsfl'

Strip Non Printable Characters

Stripping non printable characters from a string in python:

def filter_non_printable(str):
    return ''.join([c for c in str if ord(c) > 31 or ord(c) == 9])