python function wrapping not working -


i got example on https://www.youtube.com function wrapping ,but throw exception.

def addone(myfunc):      def addoneinside(myfunc):                return myfunc()+1      return addoneinside  def oldfunc():      return 3  oldfunc=addone(oldfunc)  print oldfunc() 

error :

typeerror: addoneinside() takes 1 argument (0 given)

can body explain problem.

addoneinside not need argument. myfunc accessible via context.

change

def addone(myfunc):     def addoneinside():                return myfunc()+1     return addoneinside 

Comments

Popular posts from this blog

python - Installing PyDev in eclipse is failed -

PHP OOP-based login system -

c# - Nested Internal Class with Readonly Hashtable throws Null ref exception.. on assignment -