My string module doesn't have maketrans or translate functions

Chris Angelico rosuav at gmail.com
Thu Apr 11 12:09:39 EDT 2013


On Fri, Apr 12, 2013 at 2:05 AM, Lamb <lambandme at gmail.com> wrote:
> Thanks! It worked! But why didn't I see functions : translate(), maketrans(), rstrip(), etc. listed when I called print(dir(string))?

Because they're not in the string module any more - they're methods on
str (and bytes). Try checking out dir(str) - str being the class of
your basic Unicode string now, rather than being the type of a string
of bytes - and you should see them all.

ChrisA



More information about the Python-list mailing list