Need better string methods

Fuzzyman michael at foord.net
Mon Mar 8 05:20:44 EST 2004


[snip..]

> Isn't this more readable? :
> 
> pieces = line.split(|)   # break at the bars
> nodots  = [ piece.strip(".") for piece in pieces ] # remove leading or 
> trailing dots
> clean = [" ".join(words.split()) for words in nodots] # normalise spaces
> 
> Well, there is still some complexity with the join/split mess.
> But still more readable than the regex?



This is much simpler and easier to read.
Seems like the best solution..... no need for it all to be done on one
line.

Remind me of the Perl assertion that it's a better language because
you can cram functions into huge, indecipherable single lines..... why
on earth is that an advantage ?

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list