It's that I have a little knowledge of Poo and I programmed in Python, but I haven't really seen when to use the classes, I've never used them in my practices (I'm just a student) but I would like to know when to use them and what would be the better way. Thanks.
Before asking, make sure it's a less open question, please; but welcome to SO! :D
To answer your question in a simple way, classes are used when you want to make an abstraction of a real life object (That's where OOP comes from) , such as: A car, a person, a house...
An important thing to note is that Objects like this, their classes are used in the singular , not in the plural.
On a
clase
, Person in this case, you can define attributes of the class:What goes in there is used
__init__
to initialize the attributes or any other variables of the class ; I guess you already know what parameters and arguments are, so I'll skip that part.self
it's like thethis
, but from Python, you can actually rename it to whatever you want but that's a horrible practice.Then you can create instances of the class:
Then you can add more methods, attributes...
IN SUMMARY: The classes serve us to be able to take real life objects to an abstract or imaginary plane; they can have attributes (size, name, color...), methods (Modify something, delete something, or do something in general) and you create objects from them (I mean, you create a new instance of that class, with different attributes).
I highly recommend reading the Python documentation.
Luck ;)