Tom Anderson <[EMAIL PROTECTED]> writes:

> Stian Søiland wrote:
>
> > Or what about a recursive generator?
>
> That's the sort of thing i like to see!

That can be a neat method. It's a pretty verbose way to do flatten(),
but it's a good example:

def flatten(l):
    for e in l:
        if isinstance(e, list):
            for f in flatten(e):
                yield f
        else:
            yield e

for x in flatten([0, [1, 2, [3, 4], 5], 6, 7]):
    whatever()

--
Björn Lindström <[EMAIL PROTECTED]>
Student of computational linguistics, Uppsala University, Sweden
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to