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


Yes, something like that, but without abstract types like 'basestring'. If abstract types were OK, it would suffice to use 'object'.

The use case is designing protocols that export Python objects to outer world, 'pickle' is an example. One needs to typecase through all built-in Python types and handle them in some way.

Nevertheless, my problem is solved. Thank you.


Regards,
Bartosz Tarnowski






---------------------------------------------------------------
Darmowy program do wypełniania PIT: http://linkint.pl/f2931

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to