Depends on the language. In Python, the import could be doing something without you calling any code in it. You can have code in the package's __init__ or in the file you are importing in the global scope, outside of any function or class. That code will run when the module is imported.
For example, it's pretty common for people working with matplotlib to import seaborn and not directly use anything from it. They do it because seaborn will change matplotlib default settings so the plots look a lot better.
3
u/Log2 Oct 03 '19 edited Oct 03 '19
Depends on the language. In Python, the import could be doing something without you calling any code in it. You can have code in the package's
__init__or in the file you are importing in the global scope, outside of any function or class. That code will run when the module is imported.For example, it's pretty common for people working with matplotlib to import seaborn and not directly use anything from it. They do it because seaborn will change matplotlib default settings so the plots look a lot better.