assignment, references and list comprehension

Fredrik Lundh fredrik at pythonware.com
Thu May 26 06:49:14 EDT 2005


"Jim O'D" wrote:

> I was confused as to whether the assignment of a result of a list
> comprehension created references to the orginal objects...

python never copies objects unless you tell it to, so the answer is yes.  all
the "values" you pass around are object references, not binary blobs.

> and it does (at least for my self-defined object).

trust me, it works the same way for all objects.

reading this may help:

    http://effbot.org/zone/python-objects.htm

</F> 






More information about the Python-list mailing list