8000 [3.12] gh-78612: Mark up eval() using param list (GH-115212) (#116044) · python/cpython@f85021a · GitHub
[go: up one dir, main page]

Skip to content

Commit f85021a

Browse files
[3.12] gh-78612: Mark up eval() using param list (GH-115212) (#116044)
Also mention that the 'expression' parameter can be a string. (cherry picked from commit a71e32c) Co-authored-by: Erlend E. Aasland <erlend@python.org>
1 parent 56c61cc commit f85021a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Doc/library/functions.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,20 @@ are always available. They are listed here in alphabetical order.
526526

527527
.. function:: eval(expression, globals=None, locals=None)
528528

529-
The arguments are a string and optional globals and locals. If provided,
530-
*globals* must be a dictionary. If provided, *locals* can be any mapping
531-
object.
529+
:param expression:
530+
A Python expression.
531+
:type expression: :class:`str` | :ref:`code object <code-objects>`
532+
533+
:param globals:
534+
The global namespace (default: ``None``).
535+
:type globals: :class:`dict` | ``None``
536+
537+
:param locals:
538+
The local namespace (default: ``None``).
539+
:type locals: :term:`mapping` | ``None``
540+
541+
:returns: The result of the evaluated expression.
542+
:raises: Syntax errors are reported as exceptions.
532543

533544
The *expression* argument is parsed and evaluated as a Python expression
534545
(technically speaking, a condition list) using the *globals* and *locals*
@@ -545,8 +556,7 @@ are always available. They are listed here in alphabetical order.
545556
:term:`nested scopes <nested scope>` (non-locals) in the enclosing
546557
environment.
547558

548-
The return value is the result of
549-
the evaluated expression. Syntax errors are reported as exceptions. Example:
559+
Example:
550560

551561
>>> x = 1
552562
>>> eval('x+1')

0 commit comments

Comments
 (0)
0