Question about isinstance()

Rene Pijlman reply.in.the.newsgroup at my.address.is.invalid
Thu Jan 26 13:04:13 EST 2006


Mr.Rech:
>Now, avoiding isinstace() I've written the following code:
>
>class foo(object):
>   ...
>   def __eq__(self, other):
>      try:
>         return self.an_attribute == other.an_attribute
>      except AttributeError:
>         return False

This may give unexpected results when you compare a foo with an instance
of a completely different type that happens to have an attribute called
'an_attribute'.

-- 
René Pijlman

Wat wil jij worden?  http://www.carrieretijger.nl



More information about the Python-list mailing list