summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/functions.rst14
-rw-r--r--Doc/reference/expressions.rst2
2 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index f84353c..55dd3f0 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -693,6 +693,13 @@ are always available. They are listed here in alphabetical order.
``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 <private-name-mangling>` happens at
+ compilation time, one must manually mangle a private attribute's
+ (attributes with two leading underscores) name in order to retrieve it with
+ :func:`getattr`.
+
.. function:: globals()
@@ -1512,6 +1519,13 @@ are always available. They are listed here in alphabetical order.
object allows it. For example, ``setattr(x, 'foobar', 123)`` is equivalent to
``x.foobar = 123``.
+ .. note::
+
+ Since :ref:`private name mangling <private-name-mangling>` happens at
+ compilation time, one must manually mangle a private attribute's
+ (attributes with two leading underscores) name in order to set it with
+ :func:`setattr`.
+
.. class:: slice(stop)
slice(start, stop[, step])
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 8ac6264..c8c9b46 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -77,6 +77,8 @@ When the name is bound to an object, evaluation of the atom yields that object.
When a name is not bound, an attempt to evaluate it raises a :exc:`NameError`
exception.
+.. _private-name-mangling:
+
.. index::
pair: name; mangling
pair: private; names