On 2010-04-01 13:56 PM, Ani wrote:
Hi All:I am just a beginner in python. Can anyone please tell me what is wrong with this piece of code? import copy class BaseDummyObject(object): def __init__(self): pass def __getattr__(self, item): try: return self.__dict__.__getitem__(item) except KeyError: print "Attribute Error: attr %s of class %s non-existent!" %(item, self.__class__.__name__)
You need to raise an AttributeError here. Otherwise, it implicitly returns None for all attributes not in the __dict__ and thus confusing the copy.deepcopy() code.
-- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
