Are decorators really that different from metaclasses...
Paolo Veronelli
paolo.veronelli at yahoo.it
Wed Aug 25 06:59:04 EDT 2004
Steven Bethard wrote:
> Paul Morrow <pm_mon <at> yahoo.com> writes:
>>So why don't they share a similar syntax?
>>
>> class Foo:
>> """ This is the docstring for class Foo. """
>> __metaclass__ = M
>> # body of class goes here
>>
>>
>> def baz():
>> """ This is the docstring for function baz. """
>> __features__ = synchronized, memoized
>> # body of function goes here.
>
>
>
> So the basic answer is that decorators are different from metaclasses because
> the code inside the funcdef block is executed when the function is /called/,
> while the code inside the classdef is executed when the class is /declared/.
>
This can be seen as an engine choice and IMO is very far from touching
the syntax issue.
Still I posted a question before:
Is not time to put order in the possible uses of __xxx__ with a job on
classifying them and stop looking for a better role for BDFL?
Proposals:
1) Ban a "just because I'm free of doing it" use of them as
settable/gettable attributes (in place of non special meanings attributes)
(optional actually)
2)One or more builtin classes (interfaces) useful to build their
significance,with a previous work on classifying possible levels of
interpreter instructioning:
a) Syntactical level:
_1) (re)defining operators code
_2) ......
b) Allocational level:
__init__,__new__,__metaclass__ ....????
c) Decorational:
.........
d) Globalish:
__name__,....
d) Whatelsetional ......
Good meditation to all Paolino
More information about the Python-list
mailing list