Aaron Watters <[EMAIL PROTECTED]> writes:

> I'm having trouble following your discussion
> and I suspect you might be a friend of Mark V Cheney.
> But I will focus on this one point.
>
> On May 5, 11:14 pm, [EMAIL PROTECTED] wrote:
>> If recursive generators are really useless (erect wall might not be),
>
> I would like to have recursive generators --
> for example to be able to traverse a tree
> and yield the value at every node.  Right now
> to do this you need to build a chain of generators
> from each leaf to the root of the tree (or avoid
> recursion by managing your own stack of nodes).
> Every yield must "bubble up the tree".

There is a patch that allows them:

    http://bugs.python.org/issue2292

But I don't know how it is implemented (i.e. does the 'bubbling up'
behaviour still happen behind the scene?).

Else you could use a trampoline, as I've done here:

    http://www.marooned.org.uk/~arno/python/cogenerator.html

(Scroll down to 'Flattening nested cogenerators' and 'recursive
cogenerators' - I had fun doing it but it is terribly inefficient).

-- 
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to