Direct Object Inheritance Issue

Hello All,

I’ve got a odd issue with object that inherits from Direct Object.
I’ve got a Core object which is made global by a CoreGlobal script.
(like the …GlobalScript in panda3D).
This Core object initialise sub system for GUI,etc… However if one of the subsystem inherits from DirectObject, Core object is seen as a module by the python interpreter instead of a class and so is not callable…

For information, Core inherits from DirectObject also.

I’m guessing you have something like this in one place, call it

from Core import *

and something like this in another place, call it

import Core

Then, if you import both PythonA and PythonB into PythonC with something like this:

from PythonA import *
from PythonB import *

then you might pick up Core as a module definition, or Core as a class, depending on the order which you import them.

Usually, though, this sort of problem is harder to trace through than this simple example, and involves five or six files all importing each other in different ways that are hard to follow.

In general, it’s best to avoid the “import *” syntax, for just this sort of reason. If you know the symbols you really intend to import, you can name them explicitly:

from PythonA import PythonA
from PythonB import PythonB

Never mind that Panda code doesn’t often follow this good advice; this is the voice of experience speaking. :slight_smile: