[Python-3000] Assignment decorators
Nick Coghlan
ncoghlan at gmail.com
Sat Dec 9 02:19:46 CET 2006
Talin wrote:
> One other minor brainstorm before I head off to work: I'd like function
> decorators to work with assignment statements as well as 'def' statements.
>
> Use case:
>
> class Foo:
>
> @private
> def myfunc():
> pass
>
> @private
> selected = True
>
> Rationale: The 'def' statement is a type of assignment statement, in
> that it assigns a value (a function object) to a symbol. For
> consistency, the same mechanic ought to be available to other kinds of
> assignment.
The mechanic is available, the spelling is just different:
selected = private(True)
Compare to:
myfunc = private(lambda: None)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list