- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Practical Use of Reversed Set Operators in Python?
Reversed set operators are operators that are defined as:
s & z corresponds to s.__and__(z) z & s corresponds to s.__rand__(z)
These don't make much sense in normal operations like and, add, or, etc of simple objects. However in case of inheritence, reversed operations are particularly useful when dealing with subclasses because if the right operand is a subclass of the left operand the reversed operation is attempted first. You may have different implementations in parent and child classes.
These reversed operations are also used if the first operand returns NotImplemented.
Advertisements