So here's the case,
I want to import a module, say a.py. However I don't want other modules which is imported by a.py in it.
my a.py
looks like this:
__all__ = ["fuc"]
import os
def fuc():
return 1
then, in the same dir i create a file called b.py
, which is simply prints out the modules in a:
import a
print(dir(a))
Simply running b.py gives me the output:
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'fuc', 'os']
, which 'os' is still in there.
Why is __all__
not working here?