Created
February 14, 2014 09:04
-
-
Save ami-GS/8997973 to your computer and use it in GitHub Desktop.
study for variable access
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 Var(): | |
x = "x" | |
_x = "_x" | |
__x = "__x" | |
def __init__(self): | |
self.y = "y" | |
self._y = "_y" | |
self.__y = "__y" | |
def prAll(self): | |
# print x, _x, __x # every variance evoke error | |
print self.y, self._y, self.__y #no error | |
def prAllf(v): | |
# print v.x, v._x, v.__x #v.__x evoke error | |
print v.y, v._y, v.__y #v.__y evoke error | |
var = Var() | |
#prAllf(var) #__ cannot be accessed | |
#prAllf(Var()) #__ connot be accessed | |
var.prAll() | |
Var().prAll() | |
#print var._Var_x #error | |
print var._Var__x #no error | |
#print var._Var_y #error | |
print var._Var__y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment