Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d710017

Browse files
committed
Clarify which dictionaries are updateable
by using the wording from the Py2.7 docs.
1 parent dcdadfe commit d710017

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

Doc/library/functions.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,14 +1355,18 @@ are always available. They are listed here in alphabetical order.
13551355

13561356
.. function:: vars([object])
13571357

1358-
Without an argument, act like :func:`locals`.
1358+
Return the :attr:`__dict__` attribute for a module, class, instance,
1359+
or any other object with a :attr:`__dict__` attribute.
13591360

1360-
With a module, class or class instance object as argument (or anything else that
1361-
has a :attr:`__dict__` attribute), return that attribute.
1361+
Objects such as modules and instances have an updateable :attr:`__dict__`
1362+
attribute; however, other objects may have write restrictions on their
1363+
:attr:`__dict__` attributes (for example, classes use a
1364+
dictproxy to prevent direct dictionary updates).
1365+
1366+
Without an argument, :func:`vars` acts like :func:`locals`. Note, the
1367+
locals dictionary is only useful for reads since updates to the locals
1368+
dictionary are ignored.
13621369

1363-
.. note::
1364-
The returned dictionary should not be modified:
1365-
the effects on the corresponding symbol table are undefined. [#]_
13661370

13671371
.. function:: zip(*iterables)
13681372

@@ -1481,7 +1485,3 @@ are always available. They are listed here in alphabetical order.
14811485
.. [#] Note that the parser only accepts the Unix-style end of line convention.
14821486
If you are reading the code from a file, make sure to use newline conversion
14831487
mode to convert Windows or Mac-style newlines.
1484-
1485-
.. [#] In the current implementation, local variable bindings cannot normally be
1486-
affected this way, but variables retrieved from other scopes (such as modules)
1487-
can be. This may change.

0 commit comments

Comments
 (0)