On Thu, 8 Sep 2011 17:35:53 -0700 (PDT) mdb <[email protected]> wrote:
> In a Leo script I find a portion of my outline and create a generator > > pa= p.self_and_subtree() > > If I next print the tree as so > > for px in pa: > pindent= '-- '*px.level() > print ' %s %s' % (pindent, px.h) > > I can not then print the headline of the top node > > print 'Headline of Top Node in Subtree: \n %s ' % > iter(pa).next().h > > because I have iterated through the sequence . I can print the > headline if I don't run the for loop above. How can I most easily do > both print 'Headline of Top Node in Subtree: \n %s ' % p.h ? without knowing your use case better it's hard to say why that wouldn't work. Cheers -Terry > I tried to create a copy.copy to the second step but the error is > > line 92: def __newobj__(cls, *args): > * line 93: return cls.__new__(cls, *args) > line 94: > line 95: def _slotnames(cls): > exception executing script > TypeError: object.__new__(generator) is not safe, use > generator.__new__() > > I see from messages on this listserv from 2009 that copy has been > removed from generators > but I don't understand the alternatives. Any help with a cleaner way > to code my steps or the workaround is most appreciated. I think I > only need to 'refresh' and get back to the 'top' of generator. > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en.
