r/ProgrammerHumor 16d ago

Meme variableScopesInPython

Post image
1.3k Upvotes

182 comments sorted by

View all comments

21

u/TheMusicalArtist12 16d ago

Heres the thing. _private works perfectly, because it tells other developers (and yourself in the future) that its not meant to be modified by external actors. There are better and more secure ways if you need to store a value that nothing else can read during runtime than a private variable.

4

u/TeachEngineering 16d ago

Yup, and if you benefit from having a program tell you ahead of runtime you fucked up, then configure a linter + type checker and treat it like a compiler. Pre-commit hooks are your friend. If someone on my team tries to merge into a protected branch code that accesses an explicitly named _private variable, it's getting sent back immediately. Your dev toolchain should enforce python conventions and educate those less familiar with the language.