String substitution -- reactions?
Diez B. Roggisch
deets_noospaam at web.de
Tue Nov 4 00:08:08 CET 2003
> def dequote(text, dictionary):
> """Replace quoted parts of string with dictionary entries."""
> parts = text.split('"')
> parts[1::2] = [dictionary[word] for word in parts[1::2]]
> return ''.join(parts)
Sheeesh - thats cool! I don't wanna event think of how much code this would
need in java - _with_ a regexp-package. Not to mention with the builtin
string manipulating "capabilities".
And its actually the first example of the slice-step-argument I've seen -
which doesn't mean much, but I always asked myself what use they had.
More information about the Python-list