|
|
|
|
|
by raganwald
5039 days ago
|
|
I don't know about those other complaints, I don't personally have any complaints about Python. It doesn't have multi-line lambdas, that's a design trade-off like an iPhone not having a slide-out keyboard. But it does have first-class functions. https://en.wikipedia.org/wiki/Python_syntax_and_semantics#Fi... What I was speaking to is the desire to write: class SomeExampleModel:
def setHeavyweightProperty:
triggers('cache:dirty')(
lambda self, property, value:
...something...
My understanding is that Python doesn't like two different things about this. First, the multi-line anonymous lambda being used as the target of the decorator. Second, a function being called with another function as its argument as an expression within an instance method definition.I'm open to reëducation. |
|
> First, the multi-line anonymous lambda being used as the target of the decorator.
Python has no issue with that, it's just hard to do it because Python's lambdas can only contain expressions which can be rather limited in a statements-heavy language.
> Second, a function being called with another function as its argument as an expression within an instance method definition.
That's because your "instance method definition" is not syntactically correct, the capability itself exists. A "method definition" is nothing more than a function defined within a class scope. In fact you can do things like that: