Python OOP
  • Python OOP
  • OOP class তৈরী
  • ক্লাসে প্রপার্টি যোগ করা
  • ক্লাসে মেথড যোগ করা
  • অবজেক্ট তৈরী করা
  • ক্লাস ভ্যারিয়েবল
  • ইন্সটেন্স ভ্যারিয়েবল
  • Self কীওয়ার্ড
  • অবজেক্ট এর প্রপার্টি ভ্যালু পরিবর্তন
  • অবজেক্ট এর প্রপার্টি ডিলেট করা
  • অবজেক্টকে ডিলেট করা
  • অবজেক্ট
    • প্রতিটি অবজেক্ট আলাদা
    • instance method
  • ম্যাজিক মেথড
  • Construction
  • এনক্যাপসুলেশনঃEncapsulation
  • Method
    • type()
    • Static Method
    • Specials Method
      • __str__ ()
      • __add__()
      • __eq()__
  • Inheritance
    • child class তৈরী
    • চাইল্ড অবজেক্ট প্যারেন্ট অবজেক্ট এর উত্তরাধিকার
    • super()কীওয়ার্ড
      • চাইল্ড ক্লাস হতে প্যারেন্ট ক্লাসের প্রপার্টি এক্সেস করা
      • চাইল্ড ক্লাসের নিজস্ব প্রোপার্টি এবং মেথড
    • isinstance()
      • চাইল্ড ক্লাসে প্যারেন্ট ক্লাসের মেথড কল করা
    • issubclass()
    • Method Overriding
    • super().__init__()
  • অ্যাবস্ট্রাকশন (Abstruction)
Powered by GitBook
On this page
  1. Method

Specials Method

dunder" methods

In Python OOP, double underscore methods (also called "dunder" methods) are special methods that start and end with two underscores. These methods are used to define the behavior of the class for various operations such as comparison, mathematical operations, and string representation.

Here are some commonly used double underscore methods in Python OOP:

  • __init__(self, ...) : This method is called when an object is created from the class and is used to initialize the object's attributes.

  • __str__(self) : This method is called when the object is converted to a string using the str() function or when it is printed using the print() function. It returns a string representation of the object.

  • __eq__(self, other) : This method is called when two objects are compared using the == operator. It returns True if the two objects are equal, and False otherwise.

  • __lt__(self, other) : This method is called when two objects are compared using the < operator. It returns True if the first object is less than the second object, and False otherwise.

  • __add__(self, other) : This method is called when two objects are added using the + operator. It returns a new object that is the result of the addition.

There are many other double underscore methods that can be used to define the behavior of a class. They are all prefixed and suffixed with double underscores, which makes them easy to identify.

In summary, double underscore methods are special methods in Python OOP that are used to define the behavior of a class for various operations. They all start and end with two underscores, which makes them easy to identify.

PreviousStatic MethodNext__str__ ()

Last updated 2 years ago