generator construction

Eric van Riet Paap eric2 at vanrietpaap.com
Wed Dec 4 10:34:34 EST 2002


Hi,

I was building a recursive generator which had this code in it:
for node in Nodes(child):
    yield node

As an experiment I tried this list comprehension version:
[yield node for node in Nodes(child)]

I understand that the list goes nowhere, but I thought it was a valid
construction.
Why do I get a "SyntaxError: invalid syntax" error?

- Eric







More information about the Python-list mailing list