Python: Mimic of import function -
suppose have big program many calls other libraries , want seek how work changing every function. sake of argument: have:
import numpy print numpy.sqrt(2) ...(many other calls numpy.sqrt)
and instead of importing numpy want create internal function sqrt. see that:
#import numpy def numpy: def sqrt(x): return x print numpy.sqrt(2) #now program calls own numpy.sqrt function
how it?
import numpy def sqrt(x): return x numpy.sqrt = sqrt
Comments
Post a Comment