"Collapsing" a list into a list of changes
Alan McIntyre
alan.mcintyre at esrgtech.com
Fri Feb 4 13:11:39 EST 2005
I think you're right; sometimes I'm susceptible to the "I can do that in
one line of code" temptation. :)
Since this current bit of code will probably end up in something that's
going to be maintained, I will probably stick with the straightforward
method just to be nice to the maintainer (especially if it's me!).
Jeremy Bowers wrote:
> I think that's pretty elegant; I read it and immediately understood what
> you were doing. There may be some performance tweaks you could make if you
> were doing this to large lists, and my instincts say to re-write it as an
> iterator if you use it a lot like:
>
> for item in collapse(yourList):
>
> but other than that which may not even apply, "straightforward" is
> generally a *good* thing, don't you think? :-)
>
More information about the Python-list
mailing list