[Python-ideas] string.swap()
Nick Coghlan
ncoghlan at gmail.com
Mon Apr 6 13:01:23 CEST 2009
spir wrote:
> ### proposed by Albert T. Hofkamp
> ### on the tutor mailing list
> def swapList(text, s1, s2):
> pieces = text.split(s1)
> pieces = [p.replace(s2, s1) for p in pieces]
> return s2.join(pieces)
At least putting that on ASPN as a cookbook recipe seems like a good
idea. Not so sure about making it a method though.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
More information about the Python-ideas
mailing list