Python classes

what are classes good for?
what is the main Idea of a class?
why would I use a class in the first place?

I don’t seem to understand the Idea and It’s kind of annoying to go through the lesson and feel like you don’t understand it completely :stuck_out_tongue_closed_eyes:

Have you googled? I would imaging other people have the same question:

Now, classes are not always the answer. Its not some kind of magic which is the perfect solution for everything

the other thing worth mention, is that you need to learn classes first, and that classes start to make sense when you start applying them in a project

classes are how you define your own types

>>> type(int)
<class 'type'>

>>> class something: pass
>>> type(something) is type(int)

>>> type(something) is type

It’s been awhile so don’t quote me on this.
I believe it has something more to do with the structure of Object Oriented Programming.
A class pretty much declares a type of Object for a file that you can use to structure
together more objects.

If you didn’t uses Classes, or Methods and functions inside of classes. When dealing with more complex algorthims and hunders of pages of code. It would start to be really Redudant, sloppy and hard to follow. Classes Focus on taking an Idea of an object and making it it’s own separate file to construct when you want to use that towards a larger piece of a program.

hi @gitsthebits . if you have Java Script background can you tell me if it is equivalent to this? or can anyone else tell me?

var Walker = function() {
    this.x = width/2;
    this.y = height/2;

and then somthing.prototype in order to give the objects more features?

Javascript has a very different OOP implementation. Where C and C derived languages (like python) often use inheritance, javascript uses prototype

Comparing these different OOP concepts is difficult.There are some good articles which explain this in great detail: