Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While theoretically possible, this doesn’t happen unless you’ve put effort into destabilizing the code on purpose. Folks monkeypatch to fix problems, not create them.

You can explicitly mark a nonlocal or global as well.

Now if your project needs to be impervious to malicious actors, additional safeguards will be needed. But I’ve never encountered this situation in a long career.



It's not about the why, it's about the fact that because it's possible, the language has to allow for it.

Unless I'm mistaken (and please correct me if I am), no Python linter can address the fact that

`y = myVoriable + 3`

... is valid Python code because there's no way to know a-priori that `myVoriable` isn't a valid global variable, even though human inspection makes it obvious that it's a typo on `myVariable`. For that reason, there's a practical limit on how much static error checking Python allows as per the design of the language.

Has this been changed in the past decade? If so, I should give this language another chance.


No, pyflakes will catch that and always would to my knowledge. It did have a bug or three where it would miss an occasional issue but they were bugs (not impossible to detect) and fixed years ago.

The error message is slightly obtuse, says something like "variable only used once." But is clear after inspection the first time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: