3 ms·
> Is @f a = b valid Python syntax? No, I was trying to isolate the important part. "@f def a: return b" would be the Python syntax, and I think it's misleading
by lmm 9y ago
> Is @f a = b valid Python syntax?
No, I was trying to isolate the important part. "@f def a: return b" would be the Python syntax, and I think it's misleading as sugar for, hmm, you'd have to write it as "a = f(lambda: b)" (hmm, I'd forgotten how different defining a function "natively" or as a lambda value are in Python).
You seem to be using a different definition of call-by-name to the one I'm used to. What bothers me is that a decorator can make a function behave completely differently (e.g. its body might never even be executed) but the syntax doesn't look like it can make that big a change to the function.
- KirinDave 9y agoI think that's a fair concern, although the semantics of the decorator probably make that what you want in some points. I guess in Python land, blueprint's entire purpose is to selectively fire your handlers.