Corrections - Tom
Compare changes
- Tom Reclik authored
+ 2
− 2
* Each class needs to be initialised, this is done in the function defined with ```___init___()```. The function with a double underscore before and after the keyword is called a "dunder" or "magic" method in python. These methods are not intended to be called directly (by us), but they are typically called internally by some other method or action. In our case, this "magic" method is automatically called when we create an instance of this class. This initialisation function can take one or more optinal arguments. Typically, we define variables here that define the properties of our class.
* Each class needs to be initialised, this is done in the function defined with ```___init___()```. The function with a double underscore before and after the keyword is called a "dunder" or "magic" method in python. These methods are not intended to be called directly (by us), but they are typically called internally by some other method or action. In our case, this "magic" method is automatically called when we create an instance of this class. This initialisation function can take one or more optional arguments. Typically, we define variables here that define the properties of our class.
* The indicator ```self``` indicates the instance of this class. It is not a keyword as such (we could use some other word) - but pretty much everyone uses *self* to avoid confusion. We use this to refer to, e.g., the variables or functions that are part of this class.
* A class can have one or more functions that define the functionality. They can (or not) have return values, they may operate on internal variables of the class, etc.
All variables that are part of the class are public, i.e. we cannot prevent someone to access them directly an change them. For example: