how to get names of attributes

Charles T. Smith cts.private.yahoo at gmail.com
Wed Dec 30 07:40:09 EST 2015


On Wed, 30 Dec 2015 11:51:19 +0000, Charles T. Smith wrote:

> Hi,
> 
> How can I get *all* the names of an object's attributes?  I have legacy
> code with mixed new style classes and old style classes and I need to
> write methods which deal with both.  That's the immediate problem, but
> I'm always running into the need to understand how objects are linked,
> in particular when in pdb.  The answers one always sees on StackOverflow
> is that you don't need to understand, understanding is not the pythonic
> way to do things.
> 
> Alternatively, is there are map documented somewhere - more complete
> than python/python-2.7.3-docs-html/library/stdtypes.html?
> highlight=class#special-attributes
> 
> Or, is the code available uncompiled somewhere on my machine?
> 
> Does anyone know *why* the __members__ method was deprecated, to be
> replaced by dir(), which doesn't tell the truth (if only it took an
> optional parameter to say: "be truthful")
> 
> cts


Oh!

Although the referenced doc says:

  "For compatibility reasons, classes are still old-style by default."

is it true that dictionaries are by default always new-style objects?

  (PDB)c6 = { "abc" : 123, "def" : 456}

  (PDB)isinstance (c6, dict)
  True

  (PDB)isinstance (c6, object)
  True




More information about the Python-list mailing list