how to list the attributes of a class, not an object?
Jan Kaliszewski
zuo at chopin.edu.pl
Sun Jan 24 11:58:54 EST 2010
24-01-2010, 17:37:41 Alf P. Steinbach <alfps at start.no> 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...
Regards,
*j
More information about the Python-list
mailing list