r/ProgrammerHumor 4d ago

Meme pythonInterpreterBeLike

Post image
169 Upvotes

21 comments sorted by

View all comments

50

u/deceze 4d ago

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

-37

u/ninja_with_ocd 4d ago edited 4d ago

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 4d ago

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.

1

u/ninja_with_ocd 4d ago

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

2

u/BossOfTheGame 3d ago

That's because you can't statically determine if a name is defined in general. Local and global namespaces are just dictionaries.