[Python-Dev] str.ascii_lower
Martin v. Loewis
martin at v.loewis.de
Mon Dec 29 12:59:18 EST 2003
Guido van Rossum wrote:
> But shouldnt' this work just as well if it's only for encoding names
> (which I'd hope would be ASCII themselves):
>
> def ascii_lower(s):
> return str(unicode(s).lower())
Certainly. Another implementation would be
lower_map = string.maketrans(string.ascii_upper,
string.ascii_lower)
def ascii_lower(str):
return str.translate(lower_map)
> This seems more elegant than adding yet more methods to the str type.
Ok. I'll fix it in this direction, then. There would be two copies
of this function that I can see: One for the codecs (which uses
tolower() in C code), and one in the email module.
And yes, codec names must be pure ASCII.
Regards,
Martin
More information about the Python-Dev
mailing list