delattr()+dir() problem in 2.2b1

Chuck Esterbrook ChuckEsterbrook at yahoo.com
Fri Nov 2 15:47:03 EST 2001


At 02:24 PM 11/2/2001 -0600, Skip Montanaro wrote:
>     Chuck> So dir() is now returning attributes that the object doesn't
>     Chuck> really have, but inherits. Is that intentional?
>
>Yup.  In the common case (executing dir() at the interpreter prompt), this
>is more useful than the old behavior.
>
>     Chuck> Is there another function that I should be using to get the data
>     Chuck> attributes of a particular instance and no more?
>
>I don't think so.  I think you'll either have to catch the exception or
>rummage around in the object's __dict__.

Duh! (on my part)

I just need to replace dir() with self.__dict__.keys() and get on with my 
life...

:-)

I was stuck in must-have-a-function mode since I was already using a 
function. Thanks for jarring me out of that.


-Chuck





More information about the Python-list mailing list