File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1388,6 +1388,17 @@ are always available. They are listed here in alphabetical order.
1388
1388
object allows it. For example, ``setattr(x, 'foobar', 123) `` is equivalent to
1389
1389
``x.foobar = 123 ``.
1390
1390
1391
+ .. note ::
1392
+
1393
+ setattr() attempts to update the object with the given attr/value pair.
1394
+ Whether this succeeds and what its affect is is determined by the target object.
1395
+ If an object's class defines `__slots__ `, the attribute may not be writeable.
1396
+ If an object's class defines property with a setter method, the *setattr() *
1397
+ will trigger the setter method which may or may not actually write the attribute.
1398
+ For objects that have a regular dictionary (which is the typical case), the
1399
+ *setattr() * call can make any string keyed update allowed by the dictionary
1400
+ including keys that aren't valid identifiers -- for example setattr(a, '1', 'one')
1401
+ will be the equivalent of vars()['1'] ='one'.
1391
1402
1392
1403
.. class :: slice(stop)
1393
1404
slice(start, stop[, step])
You can’t perform that action at this time.
0 commit comments