On Fri, Oct 14, 2016 at 1:42 PM, 'Terry Brown' via leo-editor <
> 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'
> 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.
Careful, the theory of operations for c.deletePositionsInList explains why
there is* no* order for deleting a set of nodes. See Code-->Core
Commands-->c.deletePositionsInList--><< theory of operation >>
It's hard to remember the argument, but the conclusion is engraved in my
bean: "the conclusion...is we must use the positions passed to
p.deletePositionsInList only as *hints* about what to do."
Reversed iterators may be safe in some situations, but usually they are
just as unsafe as forward iterators. So it seems that providing reversed
iterators is going to give people a false sense of security.
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 email@example.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.