I am new with python and PyCharm. The following code works in python console, listing the functions in the math package:
import importlib
st = 'math'
importlib.import_module(st)
dir(eval(st))
However, if the same snippet appears in the editor window and runs, the below message shows:
Traceback (most recent call last):
File "C:/Users/sywan/PycharmProjects/test/test.py", line 4, in <module>
dir(eval(st))
File "<string>", line 1, in <module>
NameError: name 'math' is not defined
Your answer is very much appreciated!!