Hacker News new | ask | show | jobs
by asolove 5041 days ago
Just FYI, he's not talking about the decorator being anonymous, he's talking about the function the decorator is wrapping being anonymous. What he means is that, since python lambda's are one-line, you can't do something like:

    ifAuthorized("admin", lambda x:
      // more code here
1 comments

> What he means is that, since python lambda's are one-line

Technically, Python's lambdas are one-expression not one-line.

Within that constraint you can create as complex lambdas as you want (you'll probably need to create helpers for things like loops, and you may be hindered by Python's limits on recursion, but FWIW Scheme's or Haskell's functions have the exact same limitation, the primary difference being they're nowhere near as statement-heavy as Python).