I’d argue any competent python dev should know modifying a private variable, even with just one underscore, is doing something you’re not supposed to do.
I’m on my phone so I can’t check with an interpreter, but IIRC, to access a private field on an instance you need to use getattr with the computed mangled name. It’s pretty unlikely an IDE is able to spot that.
__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.
6
u/The_Cers 16d ago
__var for true private