String splitting question

Duncan Booth duncan at NOSPAMrcp.co.uk
Thu Apr 10 06:00:58 EDT 2003


Jim Meyer <jmeyer at pdi.com> wrote in news:mailman.1049901770.14045.python-
list at python.org:

> Toss this one onto the heap; it feels a bit more pythonic and
> straightforward than some of the solutions offered:
> 
>   byLen = lambda a,b : cmp(len(a), len(b))
>   words = 'abcd/df/a/iiwk/abcdefghijkl/b/c'.split('/')
>   words.sort(byLen)
>   print words[-1]

I think that if you are going to do it this way it would be more 'pythonic' 
to use a decorated sort (left as an exercise for the reader).

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list