Importing modules in python | Sololearn: Learn to code for FREE!


Importing modules in python

If i can import module using this method: from module import * Can you tell me a situation where it is more advantageous to use the method below: import module Because, as of now, i could only think of one advantage but i'm not so sure if it really is.

9/5/2019 10:05:25 AM

Rex Fajardo

3 Answers

New Answer


When you use the first method, all names in module_name are placed inside the current modules namespace, this can lead to naming conflicts if there are similar names in both modules. Plus it takes more time to load all names if u use the first method. You should do it for relatively small modules


Rex Fajardo We do not know what advantage you are talking of since never mentioned it. import module_name in my opinion is advantageous only in the sense that you will have to type in less as it will import all names from the module to your program namespace. If you are using multiple modules especially user modules it can lead to name clash. It also does increase the compilation time of your program.


Thank you for both of answer, yeah name clashing was the one i was thinking of.