base classes

Jeff Shannon jeff at ccvcorp.com
Thu Aug 23 12:45:57 EDT 2001


Pete wrote:

> Oh, the problem was if I use two classes and the first is a standard
> python's class and second is written by me I need to use distinct members in
> my class. Otherwise some strange things may occur...

This is definately true.  It is most likely true for *every* language which
allows multiple inheritance.

I suppose you *could* do a really ugly workaround like:

>>> class A:
...  def foo(self):
...   print "foo!"
...
>>> class B:
...  def foo(self):
...   print "bar!"
...
>>> class C(A,B):
...  pass
...
>>> c = C()
>>> B.foo(c)
bar!
>>> A.foo(c)
foo!

But then, the whole point of inheritance is that you shouldn't have to care
about whether a method is in a base class, or *which* base class it's in.

Jeff Shannon
Technician/Programmer
Credit International






More information about the Python-list mailing list