I have a package with two modules in it. One is the __init__
file, and the other is a separate part of the package. If I try from mypackage import separatepart
, the code in the __init__
module is run, which will run unneeded code, slowing down the importing by a lot. The code in separate part won't cause any errors, and so users should be able to directly import it without importing the __init__
module.
Since I can't figure out a way to do this, I thought I should include a function in the __init__
file that does everything so nothing would be done directly, but in order to do this, I would need to have any variables set to be global. Is there any way to tell Python that all variables are global in a function, or to not run the __init__
module?