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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -