Dynamically determine base classes on instantiation
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Aug 16 13:45:28 EDT 2012
On Thu, 16 Aug 2012 10:09:08 -0700, Richard Thomas wrote:
>> a is a Foo
>> b is a Foo
>> therefore a and b are the same type
>
> What you mean here is "a and b share a common base class".
No. I mean what I said: since a and b are both direct instances of Foo,
not subclasses, they are both the same type, namely Foo.
"Share a common base class" is a much weaker statement:
class Foo: pass
class Bar(Foo): pass
a = Foo()
b = Bar()
Now we can see that a and b are NOT the same type, but they share a
common base class, Foo.
--
Steven
More information about the Python-list
mailing list