Is there any other way of importing all objects of a module? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there any other way of importing all objects of a module?

Accroding to what I know is the way to do this is by: from <modulename> import * But this way is y discouraged, as it confuses variables in your code with variables in the external module. So is there any other way of importing all objects of a module

20th Oct 2018, 7:25 AM
Sahaj
Sahaj - avatar
3 Answers
+ 1
Just use import <module> and access the object you need with <module>.<object>
20th Oct 2018, 8:22 AM
Anna
Anna - avatar
+ 1
You need to write math.pi
20th Oct 2018, 3:22 PM
Anna
Anna - avatar
0
I have tried it already but when I do this code: import math print(pi) It gives me an error: pi not defined
20th Oct 2018, 3:09 PM
Sahaj
Sahaj - avatar