type(object)
type(name, bases, dict, **kwds)
Returns the type of an object.
Parameters
The type() function takes either a single parameter object or three parameters:
name- class name; becomes the__name__attributebases- tuple listing base classes; becomes the__bases__attributedict- dictionary representing the namespace with class body definitions; becomes the__dict__attribute
Return Value
The type() function returns:
- the type of the object if only one parameter is passed
- a new type if three parameters are passed
Examples
numbers_list = [1, 2]
print(type(numbers_list))
numbers_dict = {1: 'one', 2: 'two'}
print(type(numbers_dict))
class Foo:
a = 0
foo = Foo()
print(type(foo))
# Output
<class 'list'>
<class 'dict'>
<class '__main__.Foo'>