r/learnpython • • Oct 07 '20

Classes in Python

Hey,

what is the best way to learn using classes in Python? Until now, I was using functions for almost every problem I had to solve, but I suppose it's more convenient to use classes when problems are more complex.

Thanks in advance!

324 Upvotes

97 comments sorted by

View all comments

Show parent comments

1

u/e-dude Oct 08 '20

I have a question, its more of a formality really, but is "init" really the constructor of the class? I think I heard in a youtube video that technically, the object has been constructed already when you call the "init" function, and thats why if one were to be accurate, you would not call the "init" function the constructor. Not trying to be a dick here, I am genuinely confused about it. :)

1

u/WillardWhite Oct 08 '20

I would say, if you're confused about it, pretend it doesn't matter and continue thinking about it as the constructor.

if at any point it becomes relevant to what you're developing, you might find a way to make it make sense. But for 99.9999% of cases, it's just a constructor.