Re: different ways to strip strings

2006-02-28 Thread Steven D'Aprano
On Mon, 27 Feb 2006 13:28:44 -0500, rtilley wrote: > s = ' qazwsx ' > > # How are these different? > print s.strip() > print str.strip(s) s.strip() strips white space from the start and end of string s. That is standard object-oriented behaviour: you have an instance, s, and you call its method,

Re: different ways to strip strings

2006-02-27 Thread rtilley
Kent Johnson wrote: > So... > s.strip() gets a bound method object from the class and calls it with no > additional argument. > str.strip(s) gets an unbound method object from the class and calls it, > passing a class instance as the first argument. > > Kent Thank you Kent. That's a very inform

Re: different ways to strip strings

2006-02-27 Thread Kent Johnson
Crutcher wrote: > It is something of a navel (left over feature). "xyz".strip() is (I > think) newer than string.strip() > Yes, but the question as written was about str.strip() which is an unbound method of the str class, not string.strip() which is a deprecated function in the string module.

Re: different ways to strip strings

2006-02-27 Thread Kent Johnson
rtilley wrote: > s = ' qazwsx ' > > # How are these different? > print s.strip() > print str.strip(s) They are equivalent ways of calling the same method of a str object. > > Do string objects all have the attribute strip()? If so, why is > str.strip() needed? Really, I'm just curious... there'

Re: different ways to strip strings

2006-02-27 Thread Crutcher
It is something of a navel (left over feature). "xyz".strip() is (I think) newer than string.strip() -- http://mail.python.org/mailman/listinfo/python-list

Re: different ways to strip strings

2006-02-27 Thread Crutcher
It is something of a navel (left over feature). "xyz".strip() is (I think) newer than string.strip() -- http://mail.python.org/mailman/listinfo/python-list

different ways to strip strings

2006-02-27 Thread rtilley
s = ' qazwsx ' # How are these different? print s.strip() print str.strip(s) Do string objects all have the attribute strip()? If so, why is str.strip() needed? Really, I'm just curious... there's a lot don't fully understand :) -- http://mail.python.org/mailman/listinfo/python-list