FEEDBACK WANTED: Type/class unification
wtanksle at dolphin.openprojects.net
Sun Jul 29 08:43:43 CEST 2001
On Sat, 28 Jul 2001 17:14:38 -0700, Paul Prescod wrote:
>William Tanksley wrote:
>> On Sat, 28 Jul 2001 13:07:32 -0700, Paul Prescod wrote:
>> >2. If I have an object that hides its attributes behind an __getattr__,
>> >is there any way to tweak the list returned by the API described above?
>> Not without the object's cooperation -- it's not even theoretically
>> possible to figure out what attributes __getattr__ might support.
>I am asking whether there is a way for the object to cooperate.
Yes and no. I asked later for input from people who use __getattr__; if
most or many of them follow some kind of pattern, then that pattern can be
added to the introspection API in some way. However, until they tell us,
there is no way for us to predict what that part of the API will look like.
For example, I've used getattr once for a little toy project (I shouldn't
have; I didn't need it). In short, it created any item you asked for,
with some calculated value. We could make that a standard part of the
introspection API by possibly making a query function which would answer
whether the getattr did that type of action -- the query function could
possibly even give some info on how the default value was calculated.
>I wasn't being theoretical. I was asking whether there is a function,
>method or parameter with those semantics (and obviously a more sane
I apologise. I wasn't intending to make fun; I was just playing around.
I knew you had a good question.
I don't think it has a good answer; I think that getattr is by definition
too complex to allow introspection.
-William "Billy" Tanksley
More information about the Python-list