overriding methods - two questions

Donn Ingle donn.ingle at gmail.com
Fri Nov 16 18:35:18 CET 2007

>This may help (on an old Python version):
>>>> class Sam: pass
>>>> class Judy:
> ...    def foo(self): pass
> ...
>>>> children = [Sam(), Judy(), Sam()]
>>>> for child in children: hasattr(child, "foo")
> ...
> False
> True
> False

That's not what my tests are showing. While Sam has no foo, it's coming from
(in my OP) Child (which is the parent class), so hasattr(Sam(),"foo") is
returning True.


More information about the Python-list mailing list