[Tutor] Question on UserDict class - copy function
Ketan Joshi
ktn_vrce at yahoo.com
Tue Apr 24 12:26:34 CEST 2007
Hello All,
I am very new to Python scripting. I have just started learning about Python.
I have a question regarding UserDict class.
UserDict class has a copy function which is defined as follows:
def copy(self):
if self.__class__ is UserDict:
return UserDict(self.data)
import copy
return copy.copy(self)
Here, as I understand, copy module is capable of making a copy of any python object. If so, why isn't this function defined as:
def copy(self):
import copy
return copy.copy(self)
In other words, what is the need to use the if statement first and then import the copy module?
if self.__class__ is UserDict:
return UserDict(self.data)
Thanks and Regards,
Ketan Joshi
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070424/71051414/attachment.html
More information about the Tutor
mailing list