diff -r d9c98730e2e8 -r eada2669b41f Doc/library/functions.rst --- a/Doc/library/functions.rst Sat Jul 07 13:34:50 2012 +1000 +++ b/Doc/library/functions.rst Sat Jul 07 12:57:23 2012 +0200 @@ -546,6 +546,12 @@ ``x.foobar``. If the named attribute does not exist, *default* is returned if provided, otherwise :exc:`AttributeError` is raised. + .. note:: + + Since :ref:`private name mangling ` happens at + compilation time, private attributes are not found by :func:`getattr` unless + the mangled name is used. + .. function:: globals() @@ -1181,6 +1187,11 @@ object allows it. For example, ``setattr(x, 'foobar', 123)`` is equivalent to ``x.foobar = 123``. + .. note:: + + Since :ref:`private name mangling ` only happens at + compilation time, private attributes set by :func:`setattr` are not mangled. + .. function:: slice([start,] stop[, step]) diff -r d9c98730e2e8 -r eada2669b41f Doc/reference/expressions.rst --- a/Doc/reference/expressions.rst Sat Jul 07 13:34:50 2012 +1000 +++ b/Doc/reference/expressions.rst Sat Jul 07 12:57:23 2012 +0200 @@ -80,6 +80,8 @@ pair: name; mangling pair: private; names +.. _private-name-mangling: + **Private name mangling:** When an identifier that textually occurs in a class definition begins with two or more underscore characters and does not end in two or more underscores, it is considered a :dfn:`private name` of that class.