summaryrefslogtreecommitdiffstats
path: root/Doc/library/functions.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/functions.rst')
-rw-r--r--Doc/library/functions.rst8
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index d73b279..c1a576c 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -331,6 +331,9 @@ are always available. They are listed here in alphabetical order.
returns the current global and local dictionary, respectively, which may be
useful to pass around for use by :func:`eval` or :func:`exec`.
+ See :func:`ast.literal_eval` for a function that can safely evaluate strings
+ with expressions containing only literals.
+
.. function:: exec(object[, globals[, locals]])
@@ -855,7 +858,7 @@ are always available. They are listed here in alphabetical order.
*fget* is a function for getting an attribute value, likewise *fset* is a
function for setting, and *fdel* a function for del'ing, an attribute. Typical
- use is to define a managed attribute x::
+ use is to define a managed attribute ``x``::
class C(object):
def __init__(self):
@@ -869,6 +872,9 @@ are always available. They are listed here in alphabetical order.
del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")
+ If then *c* is an instance of *C*, ``c.x`` will invoke the getter,
+ ``c.x = value`` will invoke the setter and ``del c.x`` the deleter.
+
If given, *doc* will be the docstring of the property attribute. Otherwise, the
property will copy *fget*'s docstring (if it exists). This makes it possible to
create read-only properties easily using :func:`property` as a :term:`decorator`::