Are decorators really that different from metaclasses...
paolo.veronelli at yahoo.it
Wed Aug 25 12:59:04 CEST 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?
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)
2)One or more builtin classes (interfaces) useful to build their
significance,with a previous work on classifying possible levels of
a) Syntactical level:
_1) (re)defining operators code
b) Allocational level:
d) Whatelsetional ......
Good meditation to all Paolino
More information about the Python-list