Contents

Lec18-OOP

Contents

Object-Oriented Programming

class

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class MyClass:
    def __init__(self, x, y): # constructor
        # instance variables
        self.x = x
        self.y = y
 
    def my_method(self): # non-static method
        print(self.x, self.y)
    
    @staticmethod
    def my_static_method(x, y): # static method
        print(x, y)

/lec18-oop/image.png

Python uses dynamic typing…… 😋

Binding an object to a new name does not create a new object. It creates a new reference to the same object.