Suppose I have 2 files: main.py and test.py. The contents of test.py are
def say(name):
return name
The main.py contains a single line from test import *
My question is the following: when I import main.py from REPL and run help(main)
, I want to see 'say' function as an output, but that doesn't happen. Is there any way I can accomplish this? Thanks.
You can use dir(main)
to list all the names in a module including those imported from other modules.
Notice, only members owned by the module are shown in help()
. Nevertheless, you can force your module to take ownership of imported names by explicitely indexing your module with the magic module property __all__
.
Make the contents of main.py to be:
from test import *
__all__ = ['say']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With