fork download
  1. class MyClass(object):
  2.  
  3. def __getattr__(self, method):
  4. return Request(method)
  5.  
  6. def __call__(self, **kwargs):
  7. for key, name in kwargs.items():
  8. print(key, name)
  9.  
  10.  
  11. class Request(object):
  12.  
  13. def __init__(self, method):
  14. self.method = method
  15.  
  16. def __call__(self, **kwargs):
  17. for key, name in kwargs.items():
  18. print(key, name)
  19. print('Method:', self.method)
  20.  
  21. m = MyClass()
  22. m.foo(arg1='a', arg2='b')
Success #stdin #stdout 0.02s 9936KB
stdin
Standard input is empty
stdout
arg2 b
arg1 a
Method: foo