fork download
  1. def first(*args, **kwargs):
  2. return 'first', args, kwargs
  3.  
  4.  
  5. class some_cls:
  6.  
  7. third = lambda *x, **y: ('third', x, y)
  8.  
  9. def __new__(self, *args, **kwargs):
  10. return 'second', args, kwargs
  11.  
  12. @staticmethod
  13. def fourth(*args, **kwargs):
  14. return 'fourth', args, kwargs
  15.  
  16. @classmethod
  17. def fifth(cls, *args, **kwargs):
  18. return 'fifth', args, kwargs
  19.  
  20.  
  21. def execute(code, *args, **kwargs):
  22.  
  23. actions = {
  24. 1: first,
  25. 2: some_cls,
  26. 3: some_cls.third,
  27. 4: some_cls.fourth,
  28. 5: some_cls.fifth,
  29. 6: lambda *x, **y: ('sixth', x, y)
  30. }
  31.  
  32. return actions.get(code, lambda *x, **y: 'not implemented')(*args, **kwargs)
  33.  
  34.  
  35. for code in range(10):
  36. print(code, execute(code, code+1, double=code*2, power=code**2))
  37.  
Success #stdin #stdout 0.01s 28384KB
stdin
Standard input is empty
stdout
0 not implemented
1 ('first', (2,), {'double': 2, 'power': 1})
2 ('second', (3,), {'double': 4, 'power': 4})
3 ('third', (4,), {'double': 6, 'power': 9})
4 ('fourth', (5,), {'double': 8, 'power': 16})
5 ('fifth', (6,), {'double': 10, 'power': 25})
6 ('sixth', (7,), {'double': 12, 'power': 36})
7 not implemented
8 not implemented
9 not implemented