Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
This behavior is useful when debugging: if an escape sequence is mistyped, the resulting output is more easily recognized as broken.
Wow, this sentence really threw me for a moment. I had no idea how other programming languages behave.
…which makes sense, because they don’t. The compiler just tells you to fuck off and that’s the end of that story. I guess, they can’t do that in Python…
Nope. From the spec:
“Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left in the result.”
Wow, this sentence really threw me for a moment. I had no idea how other programming languages behave.
…which makes sense, because they don’t. The compiler just tells you to fuck off and that’s the end of that story. I guess, they can’t do that in Python…
Python 3.12’s compiler tells you to fuck off
Ah, neat.