![](https://secure.gravatar.com/avatar/1e40abc43e91473ed3e5fcce74cba4bc.jpg?s=120&d=mm&r=g)
In article <110DAF75-E504-11D8-8D12-000A95A50FB2@fuhm.net>, James Y Knight <foom@fuhm.net> wrote:
@ foo or bar def f(): ...
you can write
deco = foo or bar @deco def f(): ...
An even better workaround is to write: def d(arg): return arg
@d(foo or bar) def f(): ...
However, it seems as if this restriction creates a new class of expression for no gain. It is true enough that *most* python expressions aren't useful to write after a @, but that's also true of a lot of other places an expression can be used (e.g. before a () of a function call. A list comprehension can never result in a callable object. An arithmetic operation usually won't.).
As you say, there aren't a lot of types of Python expression that return callables. The main thing this restriction seems to prevent is @lambda, and I think preventing that is a good thing. The other possibility that comes to mind is @functable[index], but I'd have to see a use case before worrying too much that it's not allowed. -- David Eppstein Computer Science Dept., Univ. of California, Irvine http://www.ics.uci.edu/~eppstein/