
Feb. 26, 2010
4:28 a.m.
Greg Ewing writes:
[x from stuff]
is a shorthand for
[x for x in stuff]
Any time you say "shorthand" you're probably violating TOOWTDI. :-)
As a bonus, the short form could probably be made more efficient, because the tuples produced by the for-loop could be put straight into the result list, instead of having to re-pack k and v into a new tuple.
This is a straightforward optimization that should be done anyway, though, if it isn't done already.