[Python-Dev] Call for defense of @decorators
"Martin v. Löwis"
martin at v.loewis.de
Thu Aug 5 23:29:35 CEST 2004
Chris King wrote:
> I should have been more specific -- I meant function attributes of
> this form (proposed and subsequently rejected somewhere else a while
> ago):
I see. So you would suggest to make a different extension *instead*
of the currently proposed one.
> def foo(a,b,c):
> .signature = 'v@:@i'
> pass
>
> I only bring this up because most (though I realize not all) use cases
> for decorators (at least in their current form) seem to involve some
> type of attribute or metadata.
Yes. Remember that Python has no declarations, though - there is, in
general, no separation between the definition of a property, and its
"enforcement". For example, classmethod, staticmethod are not considered
by the class, but declarations that have behaviour themselves. If the
container (e.g. the class) would have to evaluate the attribute, it
would need to know all attributes in advance - something which is not
really possible.
Many other languages have taken the path of making some of these
attributes built-in (which is what you are essentially proposing)
only to find out that this is insufficient, and needed to be extended
by a more general mechanism later.
Regards,
Martin
More information about the Python-Dev
mailing list