I have some script, i.e. main.py
It uses a module module.py
with some variables:
functions func1, func2...
integers int1, int2...
and so on
So, I need to extend the functionality of module.py
by a nice brand-new submodule named submodule.py
that should use variables of module.py
to deliver me new features.
Here's some code of submodule.py
:
class New_Feature:
def __init__(self, param1):
result = func1(param1, default_param)
self.attr1 = func2(result.attr2)
def inner_func(self)
return self.attr1 + int1
So I'm using from submodule import *
(I know there are no overriding names) in the module.py
code and then using module.New_Feature
in main.py
That code throws NameError: name 'func1' is not defined
So how I can import submodule to use module's variables in it?
EDIT: Just explaining why I need this. I'm writing an API wrapper with a bunch of features, but these features should be optional to not overweight main file so users can just use what they need.