Daniel Alexandre wrote:

CheckPrintable(self,message):
printablemessage = ""
for char in message:
if char in string.printable: printablemessage = printablemessage + char
return printablemessage

That would probably be best written (using Python 2.4) as:

def check_printable(self, message, printable=string.printable):
    return "".join(char for char in message if char in printable)

It would be much more efficient for one thing. And you can change printable to
be whatever you want. Unfortunately, no one knows what letters you want to
define as printable other than you, or what is printable on your codeset.
string.printable is a least-common denominator ASCII set. You can certainly
make it string.printable + "aeioun" (replacing the ASCII letters with their
accented versions in your codeset of course).

Of course I might be proven totally wrong when the i18n heavies weigh in ;)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to