Implementing deepcopy
Mr.Rech
andrea.riciputi at gmail.com
Wed Dec 7 11:46:02 EST 2005
Hi all,
I'm writing a class with some attributes which deepcopy can't cope
with, and I need some more clarifications. Sorry for my newbie
questions, but I'm a newbie indeed (or a sort of).
Suppose one of the attributes of my class is a dictionary whose values
are callable functions, such as:
>>>def foo():
..... pass
>>>def bar():
..... pass
>>>adict = dict(a = foo, b = bar)
Now if I try:
>>> anotherdict = copy.deepcopy(adict) # It doesn't work
however:
>>> anotherdict = copy.copy(adict) # works as expected
My question is: anotherdict is really a copy of adict? If so, what is
the difference between its definition and the following:
>>> yanotherdict = dict(adict)
??
Thanks in advance,
Andrea.
More information about the Python-list
mailing list