Something that just struck me. I want to add, to all the nodes on a
multi-level subtree, two child nodes. Here's the code I used:
for nd in reversed([i for i in p.subtree_iter()]): nd.insertAsLastChild().h
= 'src' nd.insertAsLastChild().h = 'clip'c.redraw()
I don't think that would have worked without the reversed(), maybe because
positions would get corrupted (maybe not, after the recent addition of .copy()
on iterator yields?), but definitely because it would end up recursively adding
the pair of child nodes to themselves.
Point is this works because you're starting at the bottom, document order wise,
and working up, so you don't encounter nodes you've just added, or corrupt any
Might be nice to have a p.subtree_reversed_iterator() to avoid creating the
list of positions, not an issue in my case (~10 positions), but such an
iterator would be useful for making changes across a whole tree without
tripping over your changes.
Heh, I guess the above would have needed an i.copy() for i... to work before
the recent .copy() change.
I'll add an enhancement item on github is this seems reasonable.
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to firstname.lastname@example.org.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.