I have a utils.py
file in which I store most of the functions that I use in my main code. Just to be safe, I import a lot of the common libraries such as numpy, pandas, etc. in the main code as well as in the utils.py
.
However, while spring-cleaning my code today, I was wondering if that is the best way to import libraries. I realize that Python does not re-load the module that has already been loaded (unless explicitly asked to reload numpy as np
). But if I import numpy as np
in utils.py
, do I need to import these libraries again in the main code files? I think that if I import libraries in the main code, then their namespace should be globally available, and thus I won't have to import them again in the utils.py
. Is that correct?