Need a specific sort of string modification. Can someone help?
Roy Smith
roy at panix.com
Sat Jan 5 09:30:45 EST 2013
In article <mailman.109.1357378077.2939.python-list at python.org>,
Chris Angelico <rosuav at gmail.com> wrote:
> result = "".join([x[int(x[0])+1:] for x in ("0"+s).replace("-","+").split("+")])
That's exceedingly clever. But bordering on line noise. At the very
least, I would break it up into a couple of lines to make it easier to
understand (plus you can print out the intermediate values to see what's
going on):
chunks = ("0"+s).replace("-","+").split("+")
result = "".join([x[int(x[0])+1:] for x in chunks]
More information about the Python-list
mailing list