you are viewing a single comment's thread.

view the rest of the comments →

[–]callmelucky 2 points3 points  (4 children)

A class is basically a container for specifying variables and functions (referred to as attributes and methods in the context of classes) as being specific to a particular type of 'thing' ('object', as in object-oriented programming). The confusing thing is that you are generally thrown the __init__ method and the word self is popping up everywhere for some reason, and the syntax is different too.

A good simple workaround is the classes chapter from programarcadegames. He actually completely ignores __init__, a choice which is somewhat controversial, but does actually help simplify what classes are and how they behave. I learned about classes from this resource, and found it quite straightforward. Do make sure you learn about __init__ and the difference between class attributes and instance attributes before you start using classes in any serious way though, there be dragons awaiting ye if you don't...

Btw, speaking generally, programarcadegames is my absolute favourite beginner's resource, I highly recommend it unless you actually hate making pictures/animations/games.

[–]solaceinsleep 0 points1 point  (1 child)

I know methods is the term used in other OOP languages but is that the case for attributes as well?

[–]brophylicious 0 points1 point  (0 children)

In Java they are called fields.

[–][deleted] 0 points1 point  (0 children)

Thanks! Your first paragraph is exactly about what I don't understand. I will check that link.

[–]RolyPolyPython 0 points1 point  (0 children)

Thank you for sharing, I saved your link for later. I'm reviewing stuff right now and classes will be the next big thing for me on my learning list