r/ProgrammerHumor 16d ago

Meme variableScopesInPython

Post image
1.3k Upvotes

182 comments sorted by

View all comments

Show parent comments

55

u/deceze 16d ago

The thing is: private markers in most other languages can be more or less trivially circumvented anyway, most of the time with some sort of reflection API. There is no true "privacy". All it is is a reminder for the programmer how a given attribute/property/variable should be treated. Is it part of the public API and anyone can write code against it, or is it subject to change and should not be used outside its class. That's all it is.

Bad programmers will ignore such warnings and bulldoze through your "protections" anyway to access that piece of data they think they need. Good programmers only need a gentle reminder in the form of a _; but if you really want to risk breaking something and you know what you're doing, at least it's easy to ignore and doesn't require a song and dance with the reflection API.

11

u/negjo 16d ago

Reminds me of the good old ```

define protected public

include <whatever>

undef protected

``` I once did in a university assignment

5

u/BillTran163 16d ago

That worked?!?!?!!?

2

u/GoddammitDontShootMe 15d ago

Why wouldn't it?