Feature: `__` private members/name mangling in classes
MrApplejuice opened this issue · 1 comments
Sorry, I would expect that this probably documented but I just cannot find it:
https://docs.python.org/3/tutorial/classes.html?highlight=name%20mangling#private-variables
Short question: Is this supported in some way? Or are there plans to support it?
It seems to be such a core-feature of Python that I kind of feel stupid to ask, I would bet that it was decided to not implement that feature somewhere/somehow, but I cannot find a reference to that decision or if it even was made?
To me this would be a very awesome feature, because it is for me the feature that avoids naming collisions in classes for something like Class-Mixins. I am reviving an old project of mine which consists converting an old piece of Python code to a web-capable implementation, and this would make those conversion efforts a LOT more convenient.
Background:
class HighscoreMixin:
pixi = None
__my_value = 1
def __init__(self):
self.__my_second_value = 2
print(list(sorted(dir(self))))
def update_highscore(self, new_score):
pass
Outputs:
[..., '__my_second_value', '__my_value', ...]
Which is not name mangled.
PS: Looks like a game, but it is actually an scientific experiment.