fork download
  1. class callable:
  2. def __init__(self, func):
  3. self.func = func
  4.  
  5. def __call__(self, *args):
  6. print(args)
  7. return self.func(*args)
  8.  
  9.  
  10. myfunc = callable(lambda x: x + 1)
  11.  
  12. @callable
  13. def f(a, b):
  14. return a + b
  15.  
  16. print(myfunc(1))
  17. print(f(1, 2))
  18. print(f('a', 'b'))
  19.  
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
(1,)
2
(1, 2)
3
('a', 'b')
ab