In the last program we did, we used a function known as __init__(). To help make programming easier, we have to know what the functions even mean. So, what in the heck does this one mean?
Alright, you could actually just look back an article and figure it out. But, if you don't want to or still don't get it, here's what I would say:
An instance of theBall (in the last article) is Ball2. __init__() will run whenever an instance is created, so Ball2 activates it. You are able to pass arguments to __init__() to make the instance with the properties set any way you want it to be. You could always look at the Ball2.py program to help jog your memory, too. I'm not gonna lie, this is sort of confusing. But, we only used it to set the object's properties, and that's probably the only thing it is used for.
There's not just __init__(), there are many functions of that type. What I'm talking about are __xxxx__() functions. We will cover them next time!
No comments:
Post a Comment