Re: Alter list items within loop

2009-06-15 Thread Lie Ryan
Tim Harig wrote: > On 2009-06-11, Duncan Booth wrote: >> Tim Harig wrote: number 3 never gets printed. Does Python make a copy of a list before it iterates through it?: >>> No, complex types are passed by reference unless explicity copied. >> *All* types are passed by reference unless

Re: Alter list items within loop

2009-06-11 Thread Tim Harig
On 2009-06-11, Duncan Booth wrote: > Tim Harig wrote: >>> number 3 never gets printed. Does Python make a copy of a list before >>> it iterates through it?: >> No, complex types are passed by reference unless explicity copied. > *All* types are passed by reference unless explicitly copied. Pytho

Re: Alter list items within loop

2009-06-11 Thread Duncan Booth
Tim Harig wrote: >> number 3 never gets printed. Does Python make a copy of a list before >> it iterates through it?: > > No, complex types are passed by reference unless explicity copied. *All* types are passed by reference unless explicitly copied. Python does make special cases for simple

Re: Alter list items within loop

2009-06-11 Thread Tim Harig
On 2009-06-11, Brendan wrote: > Can someone please explain what is happening in the output below? The > number 3 never gets printed. Does Python make a copy of a list before > it iterates through it?: You can see what is happening by printing the list as you work through the loop: >>> e = range(

Re: Alter list items within loop

2009-06-11 Thread Emile van Sebille
On 6/11/2009 11:54 AM Brendan said... Can someone please explain what is happening in the output below? you delete e[2] before displaying it. The number 3 never gets printed. Does Python make a copy of a list before it iterates through it?: No. Mods to a list while passing it is generally