Created
December 7, 2010 11:38
-
-
Save cocoatomo/731698 to your computer and use it in GitHub Desktop.
Python での 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 SecretFirst(object): | |
def __secret(self): | |
print('__secret') | |
def _SecretFirst__secret(self): | |
print('_SecretFirst__secret') | |
class SecretSecond(object): | |
def _SecretSecond__secret(self): | |
print('_SecretSecond__secret') | |
def __secret(self): | |
print('__secret') | |
if __name__ == '__main__': | |
sf = SecretFirst() | |
print(dir(sf)) | |
sf._SecretFirst__secret() # -> _SecretFirst__secret | |
ss = SecretSecond() | |
print(dir(ss)) | |
ss._SecretSecond__secret() # -> __secret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment