Skip to content
Sign UpLog In
Profile icon

Randy Stadham

@stadham
Repls
Community
stadham
stadham
shared a Post
4 years ago
Learning Python Classes
Please help: I need the dummies tutorial on how to best understand Python Classes. I can't seem to get my head around them.
ash15khng
ash15khng
There are many tutorials out there, including this. However, I'll try to explain a bit. So, classes is kind of like a blueprint for some data. Example: class Animal: is_animal = True def init(self, species): self.species = species To create an instance of a class: cat1 = Animal("cat") So now you can access stuff in it with dot notation: print(cat1.is_animal) # prints True print(cat1.species) # prints "cat" So what is the init() function? It is basically what is called when you 4 years ago