class A(object):
def __init__(self):
self.__my_var = 'a'
class B(A):
def foo(self):
print self.__my_var
error:
AttributeError: 'B' object has no attribute '_B__my_var'You learn something new everyday. Apparently prefixing with __ in classes in python causes the interpreter to mangle the name. This makes a "private" variable.
(
Read more... )
Comments 2
Reply
Reply
Leave a comment