What is the best way to use a function at the top of a module if do not know the name of the object in advance: The function might depend on user input and hence its name is stored in a variable.
import numpy window = 'hanning' w = eval('numpy.'+window+'(11)')
will be equivalent to
w = numpy.hanning(11)
However, is there a better method than using fragile/potentially dangerous
For instance, wouldn't using vars()
w = vars(numpy)[window](11)
be preferred? Any better/more pythonic ideas?