Re: iterating lists

2010-01-24 Thread Stefan Behnel
Steven D'Aprano, 23.01.2010 18:44: > On Sat, 23 Jan 2010 18:29:33 +0100, Roel Schroeven wrote: > >>> for w in l1[:]: #use copy of l1 for iteration >>> print(l1.pop()) #decomposite list >> I would prefer: >> >> while l1: >> print(l1.pop()) > > > I would prefer: > > for x in reversed(l1):

Re: iterating lists

2010-01-23 Thread Steven D'Aprano
On Sat, 23 Jan 2010 18:29:33 +0100, Roel Schroeven wrote: >> for w in l1[:]: #use copy of l1 for iteration >> print(l1.pop()) #decomposite list > > I would prefer: > > while l1: > print(l1.pop()) I would prefer: for x in reversed(l1): print(x) l1[:] = [] And garbage dispose of

Re: iterating lists

2010-01-23 Thread Stefan Behnel
ceciliasei...@gmx.de, 23.01.2010 17:29: > Arnaud Delobelle wrote: >> ceciliasei...@gmx.de writes: >> >>> As you were talking about list.pop()... >>> >>> Is anyone able to reproduce the following and explain why this happens >>> by chance? (Using 3.1.1) >>> >>> l1 = ["ready", "steady", "go"] >>> l2

Re: iterating lists

2010-01-23 Thread Roel Schroeven
Op 2010-01-23 17:29, ceciliasei...@gmx.de schreef: > > > Arnaud Delobelle schrieb: >> ceciliasei...@gmx.de writes: >> >>> As you were talking about list.pop()... >>> >>> Is anyone able to reproduce the following and explain why this happens >>> by chance? (Using 3.1.1) >>> >>> l1 = ["ready", "ste

Re: Re: iterating lists

2010-01-23 Thread ceciliaseidel
Arnaud Delobelle schrieb: ceciliasei...@gmx.de writes: As you were talking about list.pop()... Is anyone able to reproduce the following and explain why this happens by chance? (Using 3.1.1) l1 = ["ready", "steady", "go"] l2 = ["one", "two", "tree"] l3 = ["lift off"] for w in l1: Ouch...

Re: iterating lists

2010-01-23 Thread Alf P. Steinbach
* ceciliasei...@gmx.de: As you were talking about list.pop()... Is anyone able to reproduce the following and explain why this happens by chance? (Using 3.1.1) l1 = ["ready", "steady", "go"] l2 = ["one", "two", "tree"] l3 = ["lift off"] for w in l1: print(l1.pop()) #prints only "go stead

Re: iterating lists

2010-01-23 Thread Arnaud Delobelle
ceciliasei...@gmx.de writes: > As you were talking about list.pop()... > > Is anyone able to reproduce the following and explain why this happens > by chance? (Using 3.1.1) > > l1 = ["ready", "steady", "go"] > l2 = ["one", "two", "tree"] > l3 = ["lift off"] > > for w in l1: >print(l1.pop()) #

iterating lists

2010-01-23 Thread ceciliaseidel
As you were talking about list.pop()... Is anyone able to reproduce the following and explain why this happens by chance? (Using 3.1.1) l1 = ["ready", "steady", "go"] l2 = ["one", "two", "tree"] l3 = ["lift off"] for w in l1: print(l1.pop()) #prints only "go steady" - why not "ready"?? f