__metaclass__ and __author__ are already decorators
Paul Morrow
pm_mon at yahoo.com
Sat Aug 21 17:04:03 EDT 2004
Leif K-Brooks wrote:
> Paul Morrow wrote:
>
>> We just need to stop thinking of them as local function variables.
>> Instead we should think of __xxx__ attributes as describing the
>> function itself (i.e. as a decorator would), as I believe that is
>> almost always the author's intention when he/she uses such names
>> inside of a function/method definition. He wants to say something
>> about the function (who wrote it, it's version, etc.), and is probably
>> sad that it has the side-effect of creating a local variable. So it
>> probably shouldn't have that side-effect anymore. It should create a
>> function attribute instead (not to be confused with a local variable).
>
>
> Which is, like I said, assigning new meaning to an old syntax. That
> seems confusing to me; why not just create a new syntax?
Because it's not needed and would make the language more complex.
And I don't agree that this would be assigning new 'meaning' to an old
syntax. When a programmer creates a __xxx__ class attribute, he is not
trying to create a normal 'class' attribute --- one the is inherited by
instances of the class or that holds part of the 'state' of the class.
Instead, he is trying to make a meta statement about the class (who
wrote it, what happens during instance initialization, etc.). In that
sense, the meaning associated with defining __xxx__ attributes would
stay the same.
More information about the Python-list
mailing list