chopping a string

David Bear iddwb at moroni.pp.asu.edu
Mon Mar 4 19:37:07 EST 2002


there's gotta be an easier way.  I have a string 
"    something  somethingelse    "

note the leading a trailing whitespace.  I'd like to grab the first
word and strip whitespace.  I came up with

 string.join(string.split(string.strip(str))[:1])

but I'm thinking, there must be a better way?  better means (faster) (smaller)..

-- 
David Bear
College of Public Programs/ASU
480-965-8257
...the way is like water, going where nobody wants it to go



More information about the Python-list mailing list