An isalpha() that accepts underscores as well

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sun Feb 26 14:19:37 EST 2006


This is probably faster:

def alfa_(w):
    return w.replace("_", "a").isalpha()


This is another solution, but it's probably slower, you can time it:

from string import letters
_setalpha = set(letters + "_")

def alfa_2(w):
    return not (set(w) - _setalpha)

Bye,
bearophile




More information about the Python-list mailing list