append on lists

Fredrik Lundh fredrik at pythonware.com
Mon Sep 15 16:43:00 EDT 2008


Armin wrote:

 > If d should reference the list a extended with a single list element
 > you need at least two lines
 >
 > a.append(7)
 > d=a

why do you need two names for the same thing?

> and not more intuitive d = a.append(7)

unless you completely change the semantics of "append", your code would 
modify "a" as well.  how is that "more intuitive"?

side effects are bad as they are, but side effects in unexpected places 
is a really lousy idea.  I don't think you've thought this one through, 
really.

</F>




More information about the Python-list mailing list