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,
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
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.
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'
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
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
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