Created
February 4, 2016 19:54
-
-
Save disconnect3d/e720eea239d8b7488cb1 to your computer and use it in GitHub Desktop.
Python tricky name mangling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A: | |
def __a(self): | |
print("__a") | |
def _A__a(self): | |
print("_A__a") | |
def c(self): | |
self.__a() | |
self._A__a() | |
class B: | |
def _B__b(self): | |
print("_B__b") | |
def __b(self): | |
print("__b") | |
def c(self): | |
self.__b() | |
self._B__b() | |
a=A() | |
a.c() | |
a._A__a() | |
b=B() | |
b.c() | |
b._B__b() | |
# Output: | |
#_A__a | |
#_A__a | |
#_A__a | |
#__b | |
#__b | |
#__b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment