appending to list
Bob Gailer
bgailer at alum.rpi.edu
Wed Oct 1 12:06:34 EDT 2003
At 09:49 AM 10/1/2003, sud jag wrote:
>Hi,
> Iam a newbie to python. So any help on this is
>deeply appreciated
>
> If I append an instance of a class to a list will
>the list have a copy of the instance or just a
>reference to that instance ? If it is only a reference
>is there something similar to deep copy in case of
>append ?
>>> import copy
>>> List = []
>>> class A:pass
...
>>> a=A()
>>> a
<__main__.A instance at 0x0171F040>
>>> List.extend(copy.deepcopy([a]))
...
>>> List
[<__main__.A instance at 0x0171FD10>]
Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
More information about the Python-list
mailing list