[Python-Dev] Why are there no 'set' and 'frozenset' types in the 'types' module?
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Mon Apr 25 16:17:03 CEST 2011
On 02:01 pm, haael at interia.pl wrote:
>
>>Because there's no reason to include them, since they are already in
>>the root (builtins) namespace.
>>
>>You'll notice that in Python 3, the "types" module only contains types
>>which are not obviously accessed through easier means:
>
>
>OK, makes sense, but in this case it would be handy to have some list
>of all possible built-in types. I was just creating one and I nearly
>missed sets. If an entry in 'types' module is too much, there should be
>some comprehensive list in the documentation at least.
Maybe this is what you're after?
>>>pprint([t for t in object.__subclasses__() if t.__module__ ==
>>>'__builtin__'])
[<type 'type'>,
<type 'weakref'>,
<type 'weakcallableproxy'>,
<type 'weakproxy'>,
<type 'int'>,
<type 'basestring'>,
<type 'bytearray'>,
<type 'list'>,
<type 'NoneType'>,
<type 'NotImplementedType'>,
<type 'traceback'>,
<type 'super'>,
<type 'xrange'>,
<type 'dict'>,
<type 'set'>,
<type 'slice'>,
<type 'staticmethod'>,
<type 'complex'>,
<type 'float'>,
<type 'buffer'>,
<type 'long'>,
<type 'frozenset'>,
<type 'property'>,
<type 'tuple'>,
<type 'enumerate'>,
<type 'reversed'>,
<type 'code'>,
<type 'frame'>,
<type 'builtin_function_or_method'>,
<type 'instancemethod'>,
<type 'function'>,
<type 'classobj'>,
<type 'dictproxy'>,
<type 'generator'>,
<type 'getset_descriptor'>,
<type 'wrapper_descriptor'>,
<type 'instance'>,
<type 'ellipsis'>,
<type 'member_descriptor'>,
<type 'EncodingMap'>,
<type 'module'>,
<type 'classmethod'>,
<type 'file'>]
>>>
Jean-Paul
More information about the Python-Dev
mailing list