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

2013-04-11 Thread Steven D'Aprano
On Thu, 11 Apr 2013 17:56:51 +0100, Mark Lawrence wrote: > The string module is effectively dead. It's not dead, it's pining for the fjords. But seriously, the string module holds a collection of useful string constants and the Template class. -- Steven -- http://mail.python.org/mailman/li

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

2013-04-11 Thread Mark Lawrence
On 11/04/2013 16:30, Lamb wrote: Hi all, I'm really new to python and trying to figure out the basic rule and settings of it. I'm using python 3.3 and I was trying this code in python: import string s = "string. With. Punctuation?" out = s.translate(string.maketrans("",""), string.punctuation

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

2013-04-11 Thread Chris Angelico
On Fri, Apr 12, 2013 at 2:05 AM, Lamb 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)

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

2013-04-11 Thread Lamb
Thanks! It worked! But why didn't I see functions : translate(), maketrans(), rstrip(), etc. listed when I called print(dir(string))? On Thursday, April 11, 2013 11:45:05 AM UTC-4, Chris Angelico wrote: > > > import string > > > s = "string. With. Punctuation?" > > > out = s.translate(string.m

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

2013-04-11 Thread Chris Angelico
On Fri, Apr 12, 2013 at 1:30 AM, Lamb wrote: > import string > s = "string. With. Punctuation?" > out = s.translate(string.maketrans("",""), string.punctuation) Try this instead: import string s = "string. With. Punctuation?" out = s.translate(str.maketrans("", "", string.punctuation)) Due to t

My string module doesn't have maketrans or translate functions

2013-04-11 Thread Lamb
Hi all, I'm really new to python and trying to figure out the basic rule and settings of it. I'm using python 3.3 and I was trying this code in python: import string s = "string. With. Punctuation?" out = s.translate(string.maketrans("",""), string.punctuation) And I got the following error: T