From 36cdca1277f799a111c8d439d86426c229b9d239 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 5 Jan 2012 23:23:52 -0800 Subject: [PATCH] Clarify that vars() doesn't place extra restrictions on __dict__. --- Doc/library/functions.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 69f5d64ca5..991093e344 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1447,15 +1447,17 @@ available. They are listed here in alphabetical order. .. 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 - has a :attr:`__dict__` attribute), return that attribute. + Objects such as modules and instances have an updateable :attr:`__dict__` + 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:: - - The returned dictionary should not be modified: - the effects on the corresponding symbol table are undefined. [#]_ + Without an argument, :func:`vars` acts like :func:`locals`. Note, the + locals dictionary is only useful for reads since updates to the locals + dictionary are ignored. .. function:: xrange([start,] stop[, step]) -- 2.50.1