Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Every time you call MyStuff() to create an instance of your class, __init__ is called to initialize the instance. You can make __init__ take parameters beyond self and assign them to your instance.
-
Sorry, I hadn't gotten a notification for your comment. I learned using Learning Python from O'Reilly. It was extremely helpful. It can be dry at times, but it's a very informative read. After that, learn GUI programming, I recommend Qt using PyQt as it's fairly pervasive in the Python community. As far as I've seen, nothing will teach you the Object Oriented Model quite like a graphical framework.
-
@sheeponmeth thanks. OOP is running me confused. I currently learning things from Zed Shaw's LPTHW. I totally confused.
-
The basics of OOP are pretty straightforward, you just need it explained in a way that makes sense.
Everything is an object, objects can also have objects as attributes (basically a variable). Some objects need data when they're initialized, like is that 'person' object male or female, how old, what colour eyes? Eyes could be an object of their own.
Objects also have their own functions, they're typically called methods in OOP. That method belongs to that object. Objects can inherit both methods and attributes. Subclassing an object let's you take an existing object and fork it off into your own and customize it and make it more useful for your needs.
At its core, an object is really like a package of variables and functions. When you subclass an object, you're really just packaging that object inside your own.
Related Rants
What is the dunder init (__init__) doing in my Python classes?
undefined
python