on November 1st, 2006 at 06:49 am |
2. Normally people use list comprehension in python: elems = [e for e in tree.preorder()]
or write a generator expression.
3. python2.3+ has enumerate for that: for idx, e in enumerate(tree.preorder()): dostuff(...)
And as Nik mentions, generators in python are lazy evaluation and are a core language feature since python2.4 (but maybe that's besides the point?).
or write a generator expression.
3. python2.3+ has enumerate for that: for idx, e in enumerate(tree.preorder()): dostuff(...)
And as Nik mentions, generators in python are lazy evaluation and are a core language feature since python2.4 (but maybe that's besides the point?).
(Read Comments)