Python - Object

> Procedural Languages > Python > Python - Data Type

1 - About

Language - Object in Python.

In Python everything is an object including:

Advertising

3 - Comparison

Comparing objects of different types is legal.

The outcome is deterministic but arbitrary: the types are ordered by their name. Thus, a list is always smaller than a string, a string is always smaller than a tuple, etc. Mixed numeric types are compared according to their numeric value, so 0 equals 0.0, etc.

The rules for comparing objects of different types should not be relied upon; they may change in a future version of the language.

4 - Management

4.1 - id

Object id

a=1
id(a)
1370343552

4.2 - Conversion

4.2.1 - To dictionary

vars([object]) -> dictionary

4.3 - print

print(myObject)

4.4 - type

type of an object

  • Integer
print(type(1))
<type 'int'>
  • String
print(type("1"))
<type 'str'>
print(type(myClass))
<type 'type'>
  • Object
print(type(myClass()))
<class '__main__.myClass'>
Advertising

5 - Documentation / Reference