@@ -397,6 +397,7 @@ are always available. They are listed here in alphabetical order.
397
397
string. The string must be the name of one of the object's attributes. The
398
398
function deletes the named attribute, provided the object allows it. For
399
399
example, ``delattr(x, 'foobar') `` is equivalent to ``del x.foobar ``.
400
+ *name * need not be a Python identifier (see :func: `setattr `).
400
401
401
402
402
403
.. _func-dict :
@@ -738,6 +739,7 @@ are always available. They are listed here in alphabetical order.
738
739
value of that attribute. For example, ``getattr(x, 'foobar') `` is equivalent to
739
740
``x.foobar ``. If the named attribute does not exist, *default * is returned if
740
741
provided, otherwise :exc: `AttributeError ` is raised.
742
+ *name * need not be a Python identifier (see :func: `setattr `).
741
743
742
744
.. note ::
743
745
@@ -1582,6 +1584,12 @@ are always available. They are listed here in alphabetical order.
1582
1584
object allows it. For example, ``setattr(x, 'foobar', 123) `` is equivalent to
1583
1585
``x.foobar = 123 ``.
1584
1586
1587
+ *name * need not be a Python identifier as defined in :ref: `identifiers `
1588
+ unless the object chooses to enforce that, for example in a custom
1589
+ :meth: `~object.__getattribute__ ` or via :attr: `~object.__slots__ `.
1590
+ An attribute whose name is not an identifier will not be accessible using
1591
+ the dot notation, but is accessible through :func: `getattr ` etc..
1592
+
1585
1593
.. note ::
1586
1594
1587
1595
Since :ref: `private name mangling <private-name-mangling >` happens at
0 commit comments