Importing Classes Within a Module
- by CodeJoust
Currently, I have a parser with multiple classes that work together.
For Instance: TreeParser creates multiple Product and Reactant modules which in turn create multiple Element classes. The TreeParser is called by a render method within the same module, which is called from the importer.
Currently, using the class name in the imported module file works only if the file calling the module contains from module_name import *, so the classes are imported into the main namespace.
Finally, if the package has dependencies (such as re and another another module within the same folder), where is the best place to require those modules? Within the __init__.py file or within the module itself?
I don't really want to add the module name in front of every call to the class, in case I do call import *, however, is it possible to use a variable name of the current module to call the class, or use a workaround in the __init__.py file?
I'm probably used to the ruby require '' method instead of python's module system.