Sep 19, 2021
I have been learning Python recently, and whilst I'm familiar with PHP and other C-like languages, Python has been a bit of a challenge to get used to due to the different syntax. This is especially the case with objects as although Python is object oriented there are a couple of gotchas when creating custom objects.
This article sets out how to use classes and objects, but I will assume that you have a basic understanding of object oriented programming in other languages.
As a (very) quick proceeder, an object is a 'thing' in your program. They are intended to represent a thing that does something, stores information, or both. For example, a User object would be used to store information about a User, but might also do things like print out the user's name or how long they have existed for. A class is a blueprint for an object and is used to create the object. Fundamentally, the object is an encapsulation of something.