re: How Specific Are you With Your Imports and Why? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: from mymodule import funca from mymodule import funcb from somemodule import afunc I always use this syntax with the exception of pandas and n...
 

I have heard this method used many times before and that is what I was wondering! For me, it usually depends on the situation and how familiar I am with what I am working with. If i'm doing something I've done a million times, I typically just import the exact functions I need from a given class. But if I'm not sure, I'll bring in an entire class or even an entire module. Even in times when I DO know exactly what is going on, I'll bring in most of the class. Example being:

from bs4 import BeautifulSoup

I am also wondering how developers in other languages approach this kind of thing. For instance, when I was a C# developer we rarely imported and entire class and NEVER an entire namespace simply because system.web and the like were so humongous that it would take FOREVER to compile. Python tends to be a lot lighter and modular so I've not experienced that kind of specificity in it despite almost a decade using it. Thanks for the input! I love hearing the way other devs do things because there is always something I can take away from the tried and true practices of others!

code of conduct - report abuse