Overloading "and" operator in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Overloading "and" operator in Python

I'm writing a code to help figure out how priorities work in Python. For example, when calculating 4 + 5 * 8 first step is 5 * 8. Overloading operators to show their work, so to speak. I'm trying to include all the operators, not just mathematical ones. I can't find how to overload the and and or operators. Google suggests to overload & and | instead, using __and__ and __or__, but I think they have different priorities, so that wouldn't suit my purpose. Besides, I might want to include them too. Is there a way to overload the and and or operators? https://code.sololearn.com/c6hZVi8uuxF5/?ref=app

26th Feb 2023, 10:12 AM
Marijke van Bommel
Marijke van Bommel - avatar
1 Answer