Skip to content

Instantly share code, notes, and snippets.

@albertz
Created September 9, 2011 11:46
Show Gist options
  • Save albertz/1206010 to your computer and use it in GitHub Desktop.
Save albertz/1206010 to your computer and use it in GitHub Desktop.
Python function name mangling
In [1]: class Test:
...: def __foo(self): pass
...:
...:
In [2]: dir(Test)
Out[2]: ['_Test__foo', '__doc__', '__module__']
In [3]: Test.__foo
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/az/<ipython console> in <module>()
AttributeError: class Test has no attribute '__foo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment