Clarify that vars() doesn't place extra restrictions on __dict__.

This commit is contained in:
Raymond Hettinger 2012-01-05 23:23:52 -08:00
parent 24f207e99e
commit 36cdca1277
1 changed files with 9 additions and 7 deletions

View File

@ -1447,15 +1447,17 @@ available. They are listed here in alphabetical order.
.. function:: vars([object]) .. function:: vars([object])
Without an argument, act like :func:`locals`. Return the :attr:`__dict__` attribute for a module, class, instance,
or any other object with a :attr:`__dict__` attribute.
With a module, class or class instance object as argument (or anything else that Objects such as modules and instances have an updateable :attr:`__dict__`
has a :attr:`__dict__` attribute), return that attribute. attribute; however, other objects may have write restrictions on their
:attr:`__dict__` attributes (for example, new-style classes use a
dictproxy to prevent direct dictionary updates).
.. note:: Without an argument, :func:`vars` acts like :func:`locals`. Note, the
locals dictionary is only useful for reads since updates to the locals
The returned dictionary should not be modified: dictionary are ignored.
the effects on the corresponding symbol table are undefined. [#]_
.. function:: xrange([start,] stop[, step]) .. function:: xrange([start,] stop[, step])