Python Objects

nehpets0701
1 min readJan 13, 2021

--

Python is an object oriented language, and in Python, everything is an object. This means that everything has some data associated with it. These data values are called ‘attributes’. Objects are often referred to as ‘classes’. A class can be used to create any object, for example, the class below defines a dog.

Diagram of a class with four instances of a Dog class

There are many methods to help handle classes in Python. One of these is the type() method. This method returns the type of an object. There is another important method called id(). This will get the id of an object. All objects have ids associated with them and these remain constant for that object.

Mutable Objects are objects that can be changed after being created. This is useful because it gives you the ability to modify values at any point in the program. Things such as lists and dictionaries would be considered mutable because they can be changed at any time.

Immutable Objects are objects that cannot be changed after they are created. This is useful becomes should be constant and you do not want them to be accidentally changed. Built in types such as integers and floats are immutable since they cannot be changed at any time.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

nehpets0701
nehpets0701

No responses yet

Write a response