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? :-)
-- http://mail.python.org/mailman/listinfo/python-list