Why is the types module in Python 3 so small?
Python 2.7
>>> import types
>>> print(len([i for i in dir(types) if not i.startswith('__')]))
37
Python 3.2
>>> import types
>>> print(len([i for i in dir(types) if not i.startswith('__')]))
12
Python Built-in Modulesprint() and input() for I/O, Number conversion functions such as int(), float(), complex(), Data type conversions such as list(), tuple(), set(), etc.
Modules in Python can be of two types: Built-in Modules. User-defined Modules.
The Python standard library contains well over 200 modules, although the exact number varies between distributions.
The types module contains type objects for all object types defined by the standard interpreter, as Example 1-86 demonstrates. All objects of the same type share a single type object. You can use is to test if an object has a given type.
In Python 3.x, the types module removed all types that are already accessible via easier means like the builtin namespace. For example, you will see that ListType and IntType have been removed because you can simply access them via list and int respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With