I'm trying to create a generator which traverses a node and its children 
but I'm having trouble, this is what I have as a non-generator:

def traverse(node):

    g.es(node.h,color='green')

    if node.hasChildren():

        for sub_node in node.children_iter():

            traverse(sub_node)


This function will successfully output the present node and its recursive 
children when traverse(c.p) is executed.


I've tried to throw some yield statements in but i'm just not getting the 
result I'm looking for, if I put the yield in the for loop it's only 
getting the top level children.


I think my grasp of generators just isn't what I thought it was, or maybe 
recursion with generators is more complicated than I thought.


Any insight would be appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to