R. David Murray added the comment:
You are correct, this is the expected behavior. Name mangling happens only at
compilation time (see
http://docs.python.org/reference/expressions.html#atom-identifiers). A doc
note for get/setattr would probably be useful.
(I removed 3.3; that version does
New submission from Nick Craig-Wood :
I just spend a while tracking down a bug in my code which turned out to be an
unexpected behaviour of hasattr.
Running this
class Test(object):
def __init__(self):
self.__private = "Hello"
def test(self):
print(self.__private)