Operator Overloading in Python || Polymorphism in Python || Unary Operator Overloading in Python

Publicado el: 30 agosto 2024
en el canal de: US Code Academy
83
7

In this video we discuss operator overloading in Python
Operator overloading in Python allows you to redefine the behavior of operators such as +, -, *, /, ==, etc. when working with user-defined data types.

Python supports overloading of various operators, including:

1. Arithmetic operators (+, -, *, /, %, etc.)
2. Comparison operators (==, !=, )
3. Logical operators (and, or, not)
4. Assignment operators (=, +=, -=, *=, /=, etc.)
5. Unary operators (+, -, ~, etc.)
6. Bitwise operators (&, |, ^, ~, etc.)

To overload an operator in Python, you define a special method in your class with a specific name. For example:

_add_ for the + operator
_sub_ for the - operator
_mul_ for the * operator
_eq_ for the == operator
_lt_ for the operator


En esta página del sitio puede ver el video en línea Operator Overloading in Python || Polymorphism in Python || Unary Operator Overloading in Python de Duración hora minuto segunda en buena calidad , que subió el usuario US Code Academy 30 agosto 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 83 veces y le gustó 7 a los espectadores. Disfruta viendo!