24-01-2010, 16:28:26 Robert P. J. Day <rpj...@crashcourse.ca> wrote

  once again, probably a trivial question but i googled and didn't
get an obvious solution.  how to list the attributes of a *class*?

    dir(type(an_obj))

or more reliable:

    list(vars(type(an_obj)))

(dir() uses __dir__ which can be implemented in any way, and default implementation, accordinto to the docs, "attempts to produce the most relevant, rather than complete, information").

  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)".

Why you bother about creating an instance? Just do it:

list(vars(type({}.keys())))

or dir(type({}.keys()))
if dir() satisfies you.

Regards,
*j

--
Jan Kaliszewski (zuo) <z...@chopin.edu.pl>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to