jeudi 7 juillet 2016

How to redirect submodule calls to parent module in Python

My directory structure looks like this:

Module
      |
      __init.py__ (from File1 import File1...)
      File1.py
      File2.py
      Submodule
              |
               __init.py__ (Empty right now)  

I can do Module.File1.run().

But I want to do Module.Submodule.File1.run() and redirect it to Module's File1.

Is there a way to do this? Or do I have to copy all the Module files to Submodule?

EDIT 1:

If I make a File1 in Submodule (a copy of Module's File1) and do from File1 import File1 in the __init__ file in Submodule, it works.

But if I do form Module import File1 or from Module.File1 import File1, it doesn't work. I'm confused.

Aucun commentaire:

Enregistrer un commentaire