Operational Overloading | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Operational Overloading

I understand these works .Can someone make more clear why s1 N s3 will result a error if __str__ operation is not defined/ https://code.sololearn.com/ctjh7I5PjKhf/#py

29th Jul 2020, 6:17 AM
Mani
Mani - avatar
2 Answers
+ 2
It won't give an error if __str__ is not defined because Python provides a __str__ method by default
29th Jul 2020, 6:36 AM
XXX
XXX - avatar
+ 2
python then does not know, how to print the var student. to print itself , an object needs __str__ or __repr__
29th Jul 2020, 6:38 AM
Oma Falk
Oma Falk - avatar