> What I was speaking to is the desire to write:
setHeavyweightProperty = triggers('cache:dirty')(
lambda self, property, value: 'code')
is the same thing as
@triggers('cache:dirty')
def setHeavyweightProperty(self, property, value):
# code
but with the limitations of lambdas (no statements allowed)
> 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:
>>> def method_outside(self):
... return self.wedding
...
>>> class SomeType:
... whose = method_outside
...
>>> s = SomeType()
>>> s.wedding = "Amanda"
>>> s.whose()
'Amanda'
>>> method_outside(s)
'Amanda'
>>> from collections import namedtuple
>>> o = namedtuple('N', 'wedding')(wedding="Jim")
>>> method_outside(o)
'Jim'
>>>