Re: __iter__ yield

2008-03-11 Thread Lie
;<'+str(self.data)+'>' > def __iter__(self): > yield self #1 > for n in self.childs: > for nn in n.__iter__(): > yield nn #2 > > n=Node() > n.appendNode(1).appendNode(2).appendNode(3).appendNode(4) > n.

Re: __iter__ yield

2008-03-10 Thread Boris Borcic
if it's possible to make this __iter__ function with just >>>> one 'yield' intead of two? >>>> ... >>>> def __iter__(self): >>>> yield self #1 >>>> for n in self.childs: >>>>

Re: __iter__ yield

2008-03-10 Thread Paul Hankin
__ function with just > > > one 'yield' intead of two? > > > ... > > >      def __iter__(self): > > >          yield self #1 > > >          for n in self.childs: > > >              for nn in n.__iter__(): > > >                

Re: __iter__ yield

2008-03-09 Thread George Sakkis
> def __iter__(self): > > yield self #1 > > for n in self.childs: > > for nn in n.__iter__(): > > yield nn #2 > > Only one yield and shorter (but not really any simpler): > > from itertools import chain >

Re: __iter__ yield

2008-03-09 Thread Paul Hankin
On Mar 9, 8:58 pm, duccio <[EMAIL PROTECTED]> wrote: > Someone knows if it's possible to make this __iter__ function with just   > one 'yield' intead of two? > ... >      def __iter__(self): >          yield self #1 >          for n in self.chil

Re: __iter__ yield

2008-03-09 Thread Diez B. Roggisch
def __iter__(self): > yield self #1 > for n in self.childs: > for nn in n.__iter__(): > yield nn #2 Nope. There have been numerous discussions about this, introducing something like a yield_all-keyword or such thing that would replace the

__iter__ yield

2008-03-09 Thread duccio
a=data def appendNode(self, n): node=Node(n) self.childs.append(node) return node def __str__(self): return '<'+str(self.data)+'>' def __iter__(self): yield self #1 for n in self.childs: for nn i