[Python-bugs-list] [ python-Bugs-501264 ] Metaproperties
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 09 Jan 2002 06:03:23 -0800
Bugs item #501264, was opened at 2002-01-09 04:09
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=501264&group_id=5470
Category: Type/class unification
Group: Feature Request
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: Metaproperties
Initial Comment:
When defining properties in a metaclass the
setter function won't be called during the
class object construction:
---
class Meta(type):
def getname(self):
return self._name + "!"
def setname(self, name):
self._name = name
name = property(getname, setname)
class Element(object):
__metaclass__ = Meta
name = "test"
---
print Element.name results in a "AttributeError: type
object 'Element' has no attribute '_name'" but there
is a 'name' attribute in Element.__dict__
http://www.python.org/2.2/descrintro.html clearly
describes this behaviour, but is it possible to
changes this to make metaproperties work (without
having to fiddle with the dict in Meta.__new__)?
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-01-09 06:03
Message:
Logged In: YES
user_id=6380
I'm afraid this is how it's gonna be -- the metaclass
doesn't get control until after the body of the class
statement is executed. That's not easy to change. Closing
this as Won't Fix. Feel free to email me directly about
this.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=501264&group_id=5470