@@ -403,6 +403,7 @@ are always available. They are listed here in alphabetical order.
403
403
string. The string must be the name of one of the object's attributes. The
404
404
function deletes the named attribute, provided the object allows it. For
405
405
example, ``delattr(x, 'foobar') `` is equivalent to ``del x.foobar ``.
406
+ *name * need not be a Python identifier (see :func: `setattr `).
406
407
407
408
408
409
.. _func-dict :
@@ -746,6 +747,7 @@ are always available. They are listed here in alphabetical order.
746
747
value of that attribute. For example, ``getattr(x, 'foobar') `` is equivalent to
747
748
``x.foobar ``. If the named attribute does not exist, *default * is returned if
748
749
provided, otherwise :exc: `AttributeError ` is raised.
750
+ *name * need not be a Python identifier (see :func: `setattr `).
749
751
750
752
.. note ::
751
753
@@ -1598,6 +1600,12 @@ are always available. They are listed here in alphabetical order.
1598
1600
object allows it. For example, ``setattr(x, 'foobar', 123) `` is equivalent to
1599
1601
``x.foobar = 123 ``.
1600
1602
1603
+ *name * need not be a Python identifier as defined in :ref: `identifiers `
1604
+ unless the object chooses to enforce that, for example in a custom
1605
+ :meth: `~object.__getattribute__ ` or via :attr: `~object.__slots__ `.
1606
+ An attribute whose name is not an identifier will not be accessible using
1607
+ the dot notation, but is accessible through :func: `getattr ` etc..
1608
+
1601
1609
.. note ::
1602
1610
1603
1611
Since :ref: `private name mangling <private-name-mangling >` happens at
0 commit comments