Filtering out non-readable characters
Peter Hansen
peter at engcorp.com
Sat Jul 16 10:25:29 EDT 2005
Bengt Richter wrote:
> >>> identity = ''.join([chr(i) for i in xrange(256)])
> >>> unprintable = ''.join([c for c in identity if c not in string.printable])
And note that with Python 2.4, in each case the above square brackets
are unnecessary (though harmless), because of the arrival of "generator
expressions" in the language. (Bengt knows this already, of course, but
his brain is probably resisting the reprogramming. :-) )
-Peter
More information about the Python-list
mailing list