Base class and Derived class question

Ian Kelly ian.g.kelly at gmail.com
Tue Nov 6 16:34:44 CET 2012


On Tue, Nov 6, 2012 at 8:03 AM,  <cyberirakli at gmail.com> wrote:
> I've used angle brackets just for posting here,becauze this forum doesn't support [code][/code]

This is a Usenet group, not a web forum.

> Just got answer, I didn't call a class it's self.  Correct code is:
> class derivedClass(baseClassMod.baseClass):
>     def ......

Better style would be to import the class from the module in the first place:

    from baseClass import baseClass

    # ...

    class derivedClass(baseClass):
        # ...

Better yet would be to put both classes in the same file in the first
place.  Python isn't Java, where each class is an independent
compilation unit.  There is no reason to put each class in its own
separate module, and it tends to cause namespace confusion as you have
discovered.


More information about the Python-list mailing list