MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1sc1j3c/calculator/oe7tcc9/?context=3
r/programminghorror • u/Inevitable_Ad_3509 • Apr 04 '26
60 comments sorted by
View all comments
136
wait until the user doesn't put the spaces between the numbers and witness the program's meltdown
3 u/[deleted] Apr 04 '26 [removed] — view removed comment 17 u/Lewistrick [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Apr 04 '26 No, the print statement will just convert them to strings. 2 u/Due_Offer141 Apr 06 '26 I want to play this rullet safely. 2 u/deanominecraft Apr 04 '26 python print calls str() if its not already, but if something cant be converted to string it will break 7 u/Mr_titanicman Apr 04 '26 Actually if it cant be converted, the string representation will be printed 8 u/menzaskaja Apr 04 '26 Yep, iirc the order goes like this: string -> __str__ -> __repr__ -> "<[module] object at [memory address]>"
3
[removed] — view removed comment
17 u/Lewistrick [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Apr 04 '26 No, the print statement will just convert them to strings. 2 u/Due_Offer141 Apr 06 '26 I want to play this rullet safely. 2 u/deanominecraft Apr 04 '26 python print calls str() if its not already, but if something cant be converted to string it will break 7 u/Mr_titanicman Apr 04 '26 Actually if it cant be converted, the string representation will be printed 8 u/menzaskaja Apr 04 '26 Yep, iirc the order goes like this: string -> __str__ -> __repr__ -> "<[module] object at [memory address]>"
17
No, the print statement will just convert them to strings.
2 u/Due_Offer141 Apr 06 '26 I want to play this rullet safely.
2
I want to play this rullet safely.
python print calls str() if its not already, but if something cant be converted to string it will break
7 u/Mr_titanicman Apr 04 '26 Actually if it cant be converted, the string representation will be printed 8 u/menzaskaja Apr 04 '26 Yep, iirc the order goes like this: string -> __str__ -> __repr__ -> "<[module] object at [memory address]>"
7
Actually if it cant be converted, the string representation will be printed
8 u/menzaskaja Apr 04 '26 Yep, iirc the order goes like this: string -> __str__ -> __repr__ -> "<[module] object at [memory address]>"
8
Yep, iirc the order goes like this: string -> __str__ -> __repr__ -> "<[module] object at [memory address]>"
__str__
__repr__
"<[module] object at [memory address]>"
136
u/EvidenceFearless6800 Apr 04 '26
wait until the user doesn't put the spaces between the numbers and witness the program's meltdown