I have two .py files
Helper.py
SomeClass.py
lets say for the example that both files import sys
I want to import into SomeClass.py
the Helper.py
like this: from helper.py import * (because I need all functions in it)
but I don't want to remove from any of the files the import sys because these two files aren't really go hand by hand.
is there a way to to import * and exclude the imports/from...import of another file?
CodePudding user response:
You can define the __all__
module.
In your Helper.py
file, add a line
__all__ = ["foo", "bar"] # All the objects you want to export
Then in SomeClass.py
just use from helper.py import *
, this will only import what is specified in __all__
.