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

Jan Kaliszewski zuo at
Sun Jan 24 17:58:54 CET 2010

24-01-2010, 17:37:41 Alf P. Steinbach <alfps at> wrote:

>    DictKeys = type( {}.keys() )
>    dir( DictKeys )
>    list( vars( DictKeys ) )
>    help( DictKeys )
> It doesn't help much though because the only method of interrest is  
> __iter__

Not only. Please, consider:

     >>> dictkeys = type({}.keys())
     >>> set(dir(dictkeys)).difference(dir(object))
     {'__ror__', '__rsub__', '__and__', '__rand__', '__contains__',  
'__len__', '__iter__', '__or__', '__rxor__', '__xor__', '__sub__'}

And e.g. comparision-related mehods (__gt__, __le__ and so on) also are  
more interensing in dict keys views than in plain object() instances...



More information about the Python-list mailing list