Classes and Objects
Classes:
Uses the keyword
class
To leave for later you use the
pass
keyword
How a class template should look like:
The above code will fail to print as the object car1
does not have a vehicle_body
attribute. That is where the self
argument comes in. If you modify the variables assigned with self.
before it will initialize itself and you will have access to the varios items in the class
The self
keyword is used to reference itself
Technically car1 and car2 are variables but they are pointing to an object in memory
PreviousRevising the Difference between Methods and FunctionsNextClasses Attributes vs Object Attributes
Last updated