string, split, sort, None, huh?
Sean 'Shaleh' Perry
shaleh at valinux.com
Fri Feb 16 18:21:12 EST 2001
More information about the Python-list mailing list
Fri Feb 16 18:21:12 EST 2001
- Previous message (by thread): string, split, sort, None, huh?
- Next message (by thread): string, split, sort, None, huh?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 16-Feb-2001 Phlip wrote: > Thy Pon: > > Gonna split a document by linefeeds into strings, then sort the strings. > Child's play, huh? > > lines = split ( """Mary > had > a > little > lamb""", "\n" ) > > print repr(lines) > print repr(lines.sort()) > list.sort() does not return a list, it sorts it in place. >>> string = "Mary\nhad\na\nlittle\nlamb." >>> print string Mary had a little lamb. >>> from string import split >>> pieces = split(string, '\n') >>> print pieces ['Mary', 'had', 'a', 'little', 'lamb.'] >>> pieces.sort() >>> print pieces ['Mary', 'a', 'had', 'lamb.', 'little']
- Previous message (by thread): string, split, sort, None, huh?
- Next message (by thread): string, split, sort, None, huh?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list