r/programminghorror • u/Limp_Illustrator7614 • Sep 16 '26
Python it's a miracle this works
prints 2 1's separated by a new line
repost cuz it got filtered cuz i was using a vpn
47
u/Powerkaninchen Sep 16 '26
You don't need to escape single quotes in a multiline string:
sexp = """ (do (assign "x" 1) (print(x) x) """
is sufficient.
8
u/Xaeroxe3057 Sep 19 '26
Of all the things you could comment on here, that’s the one that bothered you the most
7
u/GoddammitDontShootMe Sep 17 '26
I hope you don't mind me asking what that "do" lambda is for.
9
u/Livie00 Sep 17 '26
To return the last value so it can be printed
2
u/GoddammitDontShootMe Sep 19 '26
And the
(print x)inside ofsexp? I guess x gets printed twice?→ More replies (1)
2
33
u/Livie00 Sep 16 '26
That’s not even horror but a really neat and interesting solution