Re: Idiom for "last word in a string"

2009-09-29 Thread Scott David Daniels
Grant Edwards wrote: I recently ran across this construct for grabbing the last (whitespace delimited) word in a string: s.rsplit(None,1)[1] ... I've always done this: s.split()[-1] I was wondering what the advantage of the rsplit(None,1)[1] approach would be ... Others have pointed out th

Re: Idiom for "last word in a string"

2009-09-23 Thread Peter Otten
akonsu wrote: > On Sep 23, 2:47 pm, Grant Edwards wrote: >> I recently ran across this construct for grabbing the last >> (whitespace delimited) word in a string: >> >> s.rsplit(None,1)[1] >> >> It was somewhat obvious from the context what it was supposed >> to do, but it took a bit of Googling

Re: Idiom for "last word in a string"

2009-09-23 Thread Christos Trochalakis
At Wed, 23 Sep 2009 18:47:05 + (UTC), Grant Edwards wrote: > > I recently ran across this construct for grabbing the last > (whitespace delimited) word in a string: > >s.rsplit(None,1)[1] > > It was somewhat obvious from the context what it was supposed > to do, but it took a bit of Googlin

Re: Idiom for "last word in a string"

2009-09-23 Thread Christos Trochalakis
At Wed, 23 Sep 2009 18:47:05 + (UTC), Grant Edwards wrote: > > I recently ran across this construct for grabbing the last > (whitespace delimited) word in a string: > >s.rsplit(None,1)[1] > > It was somewhat obvious from the context what it was supposed > to do, but it took a bit of Goog

Re: Idiom for "last word in a string"

2009-09-23 Thread Christos Trochalakis
At Wed, 23 Sep 2009 18:47:05 + (UTC), Grant Edwards wrote: > > I recently ran across this construct for grabbing the last > (whitespace delimited) word in a string: > >s.rsplit(None,1)[1] > > It was somewhat obvious from the context what it was supposed > to do, but it took a bit of Goog

Re: Idiom for "last word in a string"

2009-09-23 Thread Christos Trochalakis
At Wed, 23 Sep 2009 18:47:05 + (UTC), Grant Edwards wrote: > > I recently ran across this construct for grabbing the last > (whitespace delimited) word in a string: > >s.rsplit(None,1)[1] > > It was somewhat obvious from the context what it was supposed > to do, but it took a bit of Goog

Re: Idiom for "last word in a string"

2009-09-23 Thread akonsu
On Sep 23, 2:47 pm, Grant Edwards wrote: > I recently ran across this construct for grabbing the last > (whitespace delimited) word in a string: > >    s.rsplit(None,1)[1] > > It was somewhat obvious from the context what it was supposed > to do, but it took a bit of Googling to figure out exactly

Idiom for "last word in a string"

2009-09-23 Thread Grant Edwards
I recently ran across this construct for grabbing the last (whitespace delimited) word in a string: s.rsplit(None,1)[1] It was somewhat obvious from the context what it was supposed to do, but it took a bit of Googling to figure out exactly what was going on. When I want the last word in a st