Python OOPS mislanious

  • All things in python are objects

  • class - a set of things, ex — animal

  • object — is an instance of the class like — tiger

  • each class has a method which are functions but these are called using L.method_name() while for function we use func(L)

  • Each class a constructor which has the attributes of that particular class

  • this is the constructor function where a class called ATM is created

    • the __init__ method is the constructor method while the menu is the method fopr the class.

    • When the object is created for the ATM first of all the constructor is processed so for the object the pin and balance attributes or variables are created.

    • When the menu method is called on the object then it runs the menu method for the attribute

  • Constructor

    • it is a special/magic method magic method has __ in front and end of the method name.

    • these methods are not callable by the object, these run when the object are created.

    • So the constructor makes sure the objects have a common starting point,

  • What is self

    • self refers to location of the memory where the object data is stored.

    • "self" is a parameter that refers to the current instance of a class. It's used to access and modify the class's attributes and methods.

Last updated