Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43387

Re: My string module doesn't have maketrans or translate functions

References <338cca79-08c6-4c6f-89a4-d3a50ece3dee@googlegroups.com> <mailman.484.1365695113.3114.python-list@python.org> <5dbca83a-f976-4582-8022-8f8c67f759e6@googlegroups.com>
Date 2013-04-12 02:09 +1000
Subject Re: My string module doesn't have maketrans or translate functions
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.486.1365696582.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Apr 12, 2013 at 2:05 AM, Lamb <lambandme@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

My string module doesn't have maketrans or translate functions Lamb <lambandme@gmail.com> - 2013-04-11 08:30 -0700
  Re: My string module doesn't have maketrans or translate functions Chris Angelico <rosuav@gmail.com> - 2013-04-12 01:45 +1000
    Re: My string module doesn't have maketrans or translate functions Lamb <lambandme@gmail.com> - 2013-04-11 09:05 -0700
      Re: My string module doesn't have maketrans or translate functions Chris Angelico <rosuav@gmail.com> - 2013-04-12 02:09 +1000
    Re: My string module doesn't have maketrans or translate functions Lamb <lambandme@gmail.com> - 2013-04-11 09:05 -0700
  Re: My string module doesn't have maketrans or translate functions Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-11 17:56 +0100
    Re: My string module doesn't have maketrans or translate functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-12 00:17 +0000

csiph-web