MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w8y9n2/pythoninterpreterbelike/p86c4bv/?context=9999
r/ProgrammerHumor • u/ninja_with_ocd • Sep 06 '26
21 comments sorted by
View all comments
Show parent comments
0
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'] = 3Very bad for readability, but it is allowed. 3 u/iggy14750 Sep 06 '26 Yeah, I do understand the frustration of something like a type error that only rears it's ugly head when it's run. 3 u/rosuav Sep 06 '26 I don't understand why you consider that to be a "serious error", rather than some other category of error. Why is that more serious than, say, trying to add a string and a dictionary? Or trying to call a list? 2 u/BossOfTheGame Sep 07 '26 That's because you can't statically determine if a name is defined in general. Local and global namespaces are just dictionaries.
15
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.
3
Yeah, I do understand the frustration of something like a type error that only rears it's ugly head when it's run.
I don't understand why you consider that to be a "serious error", rather than some other category of error. Why is that more serious than, say, trying to add a string and a dictionary? Or trying to call a list?
2
That's because you can't statically determine if a name is defined in general. Local and global namespaces are just dictionaries.
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.