
Back in 1991, Python 1.0 was released with the goal of emphasizing code readability and to make programming accessible to a wider audience. Looking at other languages at the time, the bar was set really high for those who are new to programming.
At the time, you had to manage memory yourself, know how pointers worked, and worked with rigid syntax.
Python solved a lot of these problems by introducing the idea that programmers should have everything at their fingertips; one way they did this was by forcing everything to be an object and giving you all the functionality (type conversion, data manipulation) built-in.
Understanding objects
In many programming languages, an object combines state (data) and behavior (functions) into a single unit. It’s best demonstrated with an example - we’ll use a bank account as an example.
In a bank account, you have your money (data) and ways to interact with your money (withdraw, deposit - these are functions). If this were to be represented in Python, it would look something like this:
class BankAccount:
def __init__(self, balance):
self.balance = balance
def deposit(self, amount):
self.balance += amountWe’re able to define how we withdraw and deposit money within the class.
Everything is an object
To someone who’s new to programming, the consistency of the Python syntax makes sense:
5.bit_length()
"hello".upper()
[1, 2, 3].append(4)But in languages like C or C++, you can’t necessarily do these things straight out of the gates. For example, in C, you’d have to implement append functionality yourself:
#include <stdio.h>
#include <stdlib.h>
int main() {
int size = 3;
int *numbers = malloc(size * sizeof(int));
numbers[0] = 1;
numbers[1] = 2;
numbers[2] = 3;
// Increase size
size += 1;
numbers = realloc(numbers, size * sizeof(int));
numbers[3] = 4;
for (int i = 0; i < size; i++) {
printf("%d ", numbers[i]);
}
free(numbers);
}Okay, so… why is this important?
When working with Python, you may run into some weird quirks, like why copying variables aren’t actual copies. For instance:
>>> a = [1, 2, 3]
>>> b = a
>>> b.append(4)
>>> a
[1, 2, 3, 4]Keeping in mind that everything is an object helps explain performance differences. In Python, an integer isn’t 4 bytes like in C - it’s a full object:
>>> import sys
>>> x = 5
>>> sys.getsizeof(x) # in bytes
28» This topic sets the foundation for understanding mutability - check out the article here.
Happy coding!
📧 Join the Python Snacks Newsletter! 🐍
Want even more Python-related content that’s useful? Here’s 3 reasons why you should subscribe the Python Snacks newsletter:
Get Ahead in Python with bite-sized Python tips and tricks delivered straight to your inbox, like the one above.
Exclusive Subscriber Perks: Receive a curated selection of up to 6 high-impact Python resources, tips, and exclusive insights with each email.
Get Smarter with Python in under 5 minutes. Your next Python breakthrough could just an email away.
You can unsubscribe at any time.
Interested in starting a newsletter or a blog?
Do you have a wealth of knowledge and insights to share with the world? Starting your own newsletter or blog is an excellent way to establish yourself as an authority in your field, connect with a like-minded community, and open up new opportunities.
If TikTok, Twitter, Facebook, or other social media platforms were to get banned, you’d lose all your followers. This is why you should start a newsletter: you own your audience.
This article may contain affiliate links. Affiliate links come at no cost to you and support the costs of this blog. Should you purchase a product/service from an affiliate link, it will come at no additional cost to you.

