Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. def bar(x):
  2. # some expensive calculation
  3. <snip>
  4.  
  5. foo = lambda(x): bar(x) if bar(x) > 10 else 0
  6.  
  7. foo = lambda(x): v if (v = bar(x)) > 10 else 0
  8.  
  9. foo = lambda x: next(b if b > 10 else 0 for b in [bar(x)])
  10.  
  11. def foo(x):
  12. b = bar(x)
  13. return b if b > 10 else 0
  14.  
  15. foo = lambda(x): x if x > 10 else 0
  16. result = foo(bar(x))
  17.  
  18. lambda (x): foo(x) if foo(x) > 10 else 0 == (lambda(x): x if x > 10 else 0)(foo(x))
  19.  
  20. lambda x: next(res if res > 10 else 0 for res in (bar(x), ))
  21.  
  22. def bar(x):
  23. # some expensive calculation
  24. <snip>
  25.  
  26. def bar_threshold(x,t):
  27. y = bar(x)
  28. return y if y>t else 0
  29.  
  30. foo = lambda x: bar_threshold(x,10)
  31.  
  32. def funcdec(func):
  33. def inner(x):
  34. if func(x) > 10:
  35. return func(x)
  36. else:
  37. return 0
  38.  
  39. @funcdec
  40. def bar(x):
  41. return x * 2
  42.  
  43. foo = lambda x: bar(x)
  44.  
  45. foo(2)
  46.  
  47. foo(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement