Why can't you assign to a list in a loop without enumerate?

Fredrik Lundh fredrik at pythonware.com
Tue Oct 31 19:57:05 CET 2006

Danny Colligan wrote:

> My question is, what was the motivation for returning a deep copy of
> the value at the ith index inside a for loop instead of the value
> itself? 

I'm not sure the words "deep copy" and "value" really means what you 
think they do.  maybe you should spend a little time with Python's 
documentation, instead of making up absurd theories about how things 
might work, only to get disappointed every time reality disagrees.

> Also, is there any way to assign to a list in a for loop (with
> as little code as used above) without using enumerate?

what's wrong with using enumerate?  or a list comprehension?  or some 
other of the many different ways you can use to build a list from a set 
of values?


More information about the Python-list mailing list