[Python-Dev] PEP 318 restrictions on elements (original) (raw)

[Python-Dev] PEP 318 - generality of list; restrictions on elements

Oren Tirosh oren-py-l at hishome.net
Wed Mar 10 10:39:49 EST 2004


On Wed, Mar 10, 2004 at 07:04:38AM -0800, Guido van Rossum wrote:

> > I'd be very surprised if the interpreter cared that a decorator > > returned a callable; what should it care? > > The interpreter doesn't care; people care. That's precisely why it > should be a documented requirement.

So decorators couldn't be used to create read-only properties?

Perhaps the default behavior should be more similar to C# attributes which are simply associated with the object for introspection. Only if the decorator has a method with some special name that method would be called and the object replaced by its return value.

Builtins like staticmethod or classmethod don't HAVE to remain functions as long as they remain backward compatible. After all, functions like int and str were changed to types but kept backward compatible.

Oren


More information about the Python-Dev mailing list