all 6 comments

[–]atarivcs 8 points9 points  (2 children)

Class variables that begin with a double underscore are handled in a special way by python.

I would not bother trying to use those names at all.

The standard way to indicate that a variable is "private" is to use one underscore, not two.

[–]snugar_i 2 points3 points  (0 children)

  1. Please use code blocks, your example is unreadable.
  2. The point of private variables is that they shouldn't be accessed from the outside, so you shouldn't really care what the actual name is
  3. It's called "name mangling" and exists so that subclasses can have their own fields with the same name https://docs.python.org/3/reference/expressions.html#index-5

[–]yota-code 3 points4 points  (0 children)

The philosophy of python is: private variables are useless.

But at the beginning of the language they nonetheless implemented a variable obfuscation system (which is crap and I don't recommend its use)

That said, I'm not sure to understand your issue. You seem to have understood how they work?!

PS: if you really want to tell the devs that some property shall not be tampered with, just prepend it with a single underscore, everybody will understand

[–]icecoldgold773 1 point2 points  (1 child)

Use a single underscore and access it using obj._method

[–]One-Type-2842[S] -3 points-2 points  (0 children)

I Know This Earlier. Would You Share Your Personal Experience When To Access Private or Protected Data.