Prev | Index | NextDefining a Class
>>> class Person:
... def __init__(self, hair_colour="brown", eye_colour="blue"):
... self.hair_colour = hair_colour
... self.eye_colour = eye_colour
...
The first parameter to a method (commonly called 'self') is the object itself
__init__ is a special method; the 'constructor'
Gets called when you instaniate a new object, by calling the class directly
Used for setting up an object
An Introduction To Python