3 main parts ○ Attributes ○ Methods ○ Constructor Page 56 What is a class? ○ A blueprint for a new type of Python object ○ The blueprint describes a
PYTHON 3 version 1 61b En se partageant le savoir ne se divise pas, (héritage et polymorphisme) de classes de base dans une construction hiérarchique
x = MyClass() creates a new instance of the class and assigns this object to the local variable x Page 3 Create Object Now we can use the class named MyClass
A Example of Python Class This example includes class definition, constructor function, destructor function, Everywhere is polymorphism in Python (3)
the class (attributes are set) 3 circle objects are shown (each has Calling an object's constructor (via the class name) is a
Python 2: released in 2000, Python 3 released in 2008 What is Python? ▫ Operators ▫ Variables ▫ Functions ▫ Classes ▫ If / Else
The first method __init__() is a special method, which is called class constructor or initialization method that Python calls when you create a new instance
Classes and object oriented programming in Python vs other OOP languages; x = 3 When a function is returned, it remembers the variables declared
A Python module is a file with the same name (plus the py extension) • Like Java import, C++ include • Three formats of the command: import somefile