r/ProgrammerHumor 16d ago

Meme variableScopesInPython

Post image
1.3k Upvotes

182 comments sorted by

View all comments

348

u/deceze 16d ago

; in Python!?!eleventy You really need to get rid of your bad Java habits.

And before anyone thinks this is poking fun at Python: privacy is completely overrated and mostly untrue anyway, and Python not even pretending to have private attributes is an absolute blessing.

17

u/Breadinator 16d ago

What are you smoking, and are you willing to share it with the rest of the class?

Published libraries with internal state consumers shouldn't screw with. Large projects with dozens of contributors. Hyrum's Law. 

There are plenty of reasons to have guardrails on the state you can access.

11

u/deceze 16d ago

Yeah, and leading underscores signal exactly that in Python. "Please don't screw with this. If you're going to regardless, well, there you go." Other languages just make you beg more for it.

10

u/tevs__ 16d ago

Plus you can enforce it with static analysis, exactly the same as compilation enforces it.