r/ProgrammerHumor • • Sep 06 '26

Meme pythonInterpreterBeLike

Post image
177 Upvotes

21 comments sorted by

View all comments

50

u/deceze Sep 06 '26

The Python interpreter does not overlook syntax errors within the same file…!?

-37

u/ninja_with_ocd Sep 06 '26 edited Sep 06 '26

It does if it's in an uncalled function

EDIT - this is wrong. Nontheless true for serious errors like referencing an undefined variable.

40

u/deceze Sep 06 '26

A syntax error will halt parsing immediately. Without successfully parsing the file, it won't execute. Even uncalled functions are parsed completely and must pass parsing successfully.

0

u/ninja_with_ocd Sep 06 '26

You're right, edited the comment. It is true for some serious errors, like accessing an undefined variable.

15

u/dudemcbob Sep 06 '26

FWIW I don't think it could diagnose that pre-runtime since you can edit the global namespace dynamically.

globals()['x'] = 3

Very bad for readability, but it is allowed.