4 ms·
"And why would an integer have a method for converting itself to a string? Or an array?" You know that under the covers in Python str(1) works by calling (1)._
by earthboundkid 17y ago
"And why would an integer have a method for converting itself to a string? Or an array?"
You know that under the covers in Python str(1) works by calling (1).__str__(), right? That's why you can make str(my_custom_class) work.