how to list the attributes of a class, not an object?

Alf P. Steinbach alfps at start.no
Sun Jan 24 10:56:46 EST 2010


* Robert P. J. Day:
>   once again, probably a trivial question but i googled and didn't
> get an obvious solution.  how to list the attributes of a *class*?
> 
>   eg., i was playing with dicts and noticed that the type returned by
> the keys() method was "dict_keys".  so i'm now curious as to the
> attributes of the dict_keys class.  but i don't know how to look at
> that without first *creating* such an instance, then asking for
> "dir(dk)".

Like,

   dir( list )

where 'list' is the built-in type.

There's a pretty-printer for that somewhere, but I can't recall.

And as I also recommended in your thread "examining an initial, pristine python3 
shell session",

   help( list )

or more generally

   help( "list" )


>   surely there's a simpler way just using the class name, no?

Yes. :-)


> rday
> 
> p.s.  any recommendations for the most concise reference sheet for
> python 3 that exists?  being able to print off the entire language
> spec on two or four pages and tacking it up in front of me would be
> just ducky.  thanks.

Sorry, don't know.


Cheers & hth.,

- Alf



More information about the Python-list mailing list