I am new to python. I have a very basic question. When we use the following command (I understand its not efficient to import everything using *) from _ (any module name) import *
How can I check the things that get imported using the above command?
I am new to python. I have a very basic question. When we use the following command (I understand its not efficient to import everything using *) from _ (any module name) import *
How can I check the things that get imported using the above command?
You can use dir to see what names are in the current module. By comparing the names before and after the import you can see what's imported:
>>> vars_before_import = set(dir())
>>> from json import *
>>> set(dir()) - vars_before_import
set(['load', 'JSONEncoder', 'dump', 'vars_before_import', 'JSONDecoder', 'dumps', 'loads'])
To exclude vars_before_import:
>>> set(dir()) - vars_before_import - {'vars_before_import'}
set(['load', 'JSONEncoder', 'dump', 'JSONDecoder', 'dumps', 'loads'])
NOTE
This won't catch objects that have been replaced (e.g. you defined load before importing everything in json).