[Tutor] Attribute.Error: 'list' object has no attribute strip
Gregor Lingl
glingl@aon.at
Fri Feb 28 15:19:01 2003
vicki@stanfield.net schrieb:
>Thanks for all the help with the listbox callback
>stuff. Now onto something else. I am trying to use the
>strip function on the data which is returned from a
>getcurselection() call on that same listbox. What is
>returned is in the following format (number will vary):
>
>('06',)
>
>I want to get only the number part, so I use the
>following:
>
>command=string.strip([(),])
>
>The error I get is
>
>Attribute.Error: 'list' object has no attribute strip
>
>I am including the string module. Can anyone tell me
>what I am missing (this time)?
>
>
In string.py the functino string is implemented like this:
def strip(s):
"""strip(s) -> string
Return a copy of the string s with leading and trailing
whitespace removed.
"""
return s.strip()
That is, is uses the strip - *method* of type string.
If cou call it with a list as argument, it will complain, that list
don't have a method called strip.
In fact I cannot imagine, what you expected the rsult of
string.strip([(),])
to be, as the documentation about string.stript says:
strip(s[, chars])
Return a copy of the string with leading and trailing characters
removed. If chars is omitted or None, whitespace characters are removed.
If given and not None, chars must be a string; the characters in the
string will be stripped from the both ends of the string this method is
called on.
Regards, Gregor
>--vicki
>
>_______________________________________________
>Tutor maillist - Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>