Re: strange list comprehension on generator

2007-08-29 Thread [EMAIL PROTECTED]
On Aug 29, 6:50 am, Roland Puntaier <[EMAIL PROTECTED] automation.com> wrote: > def changeOne(aa,idx): > aa[idx]=not aa[idx] > yield aa > for i in range(idx): > for x in changeOne(aa,i): > yield x > > def changeOneOrder(aa): > yield aa > for i in range(len(aa)): > for x in c

Re: strange list comprehension on generator

2007-08-29 Thread Martin v. Löwis
> #this does not return the way I would expect. why? You yield the very same list object all the times. So when you make a later change, all earlier results will get changed, too (since they are the same object). Of course, it won't affect the terminal output, so you don't see that the older value

Re: strange list comprehension on generator

2007-08-29 Thread Bjoern Schliessmann
No greeting, no text? Pity. Roland Puntaier wrote: > def changeOne(aa,idx): > aa[idx]=not aa[idx] > yield aa > for i in range(idx): > for x in changeOne(aa,i): > yield x > > def changeOneOrder(aa): > yield aa > for i in range(len(aa)): > for x in changeOne(aa,i): >