+ 1

(Python) Why importing only one "part" when we can import all ?, how does this affect the code ?

I was looking for some codes and I'm just wandering, since I'm learning Python I want to know, how bigger is the difference from example: Import abc.def Import abc From abc Import * I know that the first one Import just the part that you want and the last one Import everything but, how is that used ?, why don't just import everything?.

14th Aug 2019, 4:31 PM
Jessica Campos
Jessica Campos - avatar
2 Respuestas
+ 5
importing only parts of a modul / library is done to keep memory consumption low. There are large modules and if you only need one function or method from it, it's a good practice to only import the once you need.
14th Aug 2019, 5:09 PM
Lothar
Lothar - avatar
+ 1
thanks :)
14th Aug 2019, 6:01 PM
Jessica Campos
Jessica Campos - avatar