[Python-3000] Assignment decorators, anyone?
greg.ewing at canterbury.ac.nz
Thu Jun 8 12:14:34 CEST 2006
I think I've come across a use case for @decorators
on assignment statements.
I have a function which is used like this:
my_property = overridable_property('my_property', "This is my property.")
However, it sucks a bit to have to write the name of
the property twice. I just got bitten by changing the
name of one of my properties and forgetting to change
it in both places.
If decorators could be applied to assignment statements,
I'd be able to write it as something like
my_property = "This is my property."
(This would require the semantics of assignment
decoration to be defined so that the assigned name
is passed to the decorator function as well as the
value being assigned.)
On the other hand, maybe this is a use case for
the "make" statement that was proposed earlier.
More information about the Python-3000