Rather than defining
from numpy import cos as cos
from numpy import arccos as arccos
and so on, can I do something like
trigfunctions = ('cos','arccos','sin','arcsin','tan','arctan')
for method in trigfunctions:
setattr(HERE,method,getattr(numpy,method))
Where HERE is either global space (or possibly, local function environment)? This would make it easier to define general functions based on cos, arccos without specifying the namespace, and loading the appropriate function from the desired module (e.g., math if numpy is not available). I realize that this can lead to errors when applied very generally, but in some small instances it would be useful.
If you mean importing with the same name, simply leave off the
as:Beyond that, you can use
globals()to get the symbol table for the current module:You can also use
sys.modules[__name__]to reference the current module.