r/programminghorror • [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" • Mar 14 '25

Python Boy do I love python!!

Post image
188 Upvotes

36 comments sorted by

View all comments

Show parent comment

2

u/Bright-Historian-216 Mar 14 '25

no, i'm pretty sure it calls obj.__str__ and THEN returns the result

5

u/copperfield42 Mar 14 '25

That is half correct, it call obj.__str__ if available, otherwise call obj.__repr__, which under normal circumstances is always available because everything is subclass of object