python - TypeError: 'NoneType' object is not callable in factory function -


#!/usr/bin/python  def maker(n):   def action(x):    return x*n    return action  f=maker(2) print f(3) 

i have problem here type error.how solve 2 arguments problem,one fixed.

you need put return action out of action function :

def maker(n):   def action(x):    return x*n   return action  f=maker(2) print f(3) 

result:

6 

note in factory function must return inner function result of main function.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -