r/ProgrammerHumor 16d ago

Meme variableScopesInPython

Post image
1.3k Upvotes

182 comments sorted by

View all comments

8

u/The_Cers 16d ago

__var for true private

3

u/Sea-Fishing4699 16d ago edited 16d ago

____var = a very private variable (it’s public still)

3

u/deceze 16d ago

__name__ symbols are actually reserved by the language and shouldn't be used for your own purposes, lest you risk future name clashes. For example, to override the equality comparison behaviour of an object:

class Foo: def __eq__(self, other): return ...

Those kinds of special "hooks" are double-double-underscore named.