The title is a little hard to understand, but my question is simple.
I have a program that needs to take the sqrt()
of something, but that's the only thing I need from math
. It seems a bit wasteful to import the entire module to grab a single function.
I could say from math import sqrt
, but then sqrt()
would be added to my program's main namespace and I don't want that (especially since I plan to alter the program to be usable as a module; would importing like that cause problems in that situation?). Is there any way to import only that one function while still retaining the math.sqrt()
syntax?
I'm using Python 2.7 in this specific case, but if there's a different answer for Python 3 I'd like to hear that too for future reference.