I created a module named util
that provides classes and functions I often use in Python.
Some of them need imported features. What are the pros and the cons of
Like flying sheep's answer, I agree that the others are right, but I put imports in other places like in __init__()
routines and function calls when I am DEVELOPING code. After my class or function has been tested and proven to work with the import inside of it, I normally give it its own module with the import following PEP8 guidelines. I do this because sometimes I forget to delete imports after refactoring code or removing old code with bad ideas. By keeping the imports inside the class or function under development, I am specifying its dependencies should I want to copy it elsewhere or promote it to its own module...