On Apr 1, 12:10 pm, Robert Kern <robert.k...@gmail.com> wrote: > 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. >
Thanks Robert. So I raised the exception and now everything looks good. So what's happening here? When a certain attribute is not available in the __dict__ and an exception is raised, who's catching it? Ani -- http://mail.python.org/mailman/listinfo/python-list