On 12/8/06, Talin <[EMAIL PROTECTED]> 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.
>
> -- Talin
> _______________________________________________
> Python-3000 mailing list
> Python-3000@python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-3000/ironfroggy%40gmail.com
>

Although I agree with the merits of this, to some degree (I even
thought of it previously), I would have to now disagree because the
overall value is probably not worth the resulting confusion. The
confusion is both in the look of the code (which has been pointed out)
and the lack of usefulness compared to function decorators.

I'm all for class decorators, of course. Any kind of assignment that
does not simple bind the name to a given expression is up for
decorators, I say. Even though that includes the following, possibly
terrible, example:

@max
for largest in list_of_pairs:
    print larget

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to