In object-oriented programming languages like Python, an object is an entity that contains data along with associated metadata or functionality, these data contained in an object are known as the object’s data attributes.
- These attributes are simply variables that reference the data.
- The procedures or series of activities conducted in a certain order or manner that an object performs are known as the methods.
- An object’s methods are functions that perform operations on the objects data attributes.
- In Python everything is an object, which means every entity has some metadata called “attributes” and associated functionality called “methods”. These attributes and methods are accessed.
Objects:
An Identity(id)/ (type)
A value(mutable or immutable .
type() -
The type() function returns the type of the object. The returned type is a class as each object is an instance of the corresponding class. Class is a structure used to describe and access a particular value’s information and methods.
The id()-
built-in returns an unique id for the specified object. id() is assigned to every object when it is created.
- Python, the object’s id is an integer memory address that is unique for the given object and remains constant during its lifetime.
- Two objects with non-overlapping lifetimes may have the same id() value.