[Python-Dev] assymetry in descriptor behavior
Guido van Rossum
Mon, 24 Feb 2003 07:40:34 -0500
> However, I think it might also cost an extra property object per
> wrapped class, unless I can find a way to get the class and its
> instance to share the property. Hmm, feels a bit hack-ish to me now
> that you mention it. Maybe option 2 is better after all. But then,
> do I want to implement tp_getattr or tp_getattro? I don't recall the
Definitely tp_getattro. The difference is that tp_getattr takes a C
string argument and tp_getattr takes a Python string object.
> > When you call it yourself (rather than when it is called as a result
> > of __getattribute__).
> When do you call it yourself?
I've never called it myself except in the test suite.
> > I suppose this is a bit redundant.
> I guess; I don't know. I'm trying to understand whether "callable
> with one or two arguments" is really part of the requirements for use
> as a property method, or just something that got thrown in there.
The latter. The type argument was an afterthought -- I had originally
not thought about class attribute access at all.
--Guido van Rossum (home page: http://www.python.org/~guido/)