Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python 3 types module

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
like image 946
Volodymyr Pavlenko Avatar asked Jul 16 '12 10:07

Volodymyr Pavlenko


People also ask

What are the 3 modules in Python?

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.

What are the types of Python module?

Modules in Python can be of two types: Built-in Modules. User-defined Modules.

How many modules are in Python?

The Python standard library contains well over 200 modules, although the exact number varies between distributions.

What is types module?

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.


1 Answers

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.

like image 85
ToBeReplaced Avatar answered Sep 29 '22 10:09

ToBeReplaced