egbert <[EMAIL PROTECTED]> writes: > The string method isalpha() returns True when all characters in the > string are alphabetic. Unfortunately the underscore is not alphabetic. > A function that does what I need is: > > def alfa_(w): > return "".join(w.split("_")).isalpha() > > but for the kind of strings that I have this is about ten times > slower than isalpha() sec. Any suggestions ? > Thanks.
what about def alfa_(w): return w.isalpha() or w.find('_') != -1 ? but yes it does scan `w' twice .. You could also do something like: def alfa_(w): for c in w: if not c.isalpha() and not c == '_': return False return True -- lg -- http://mail.python.org/mailman/listinfo/python-list