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 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to