File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -526,9 +526,20 @@ are always available. They are listed here in alphabetical order.
526
526
527
527
.. function :: eval(expression, globals=None, locals=None)
528
528
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.
532
543
533
544
The *expression * argument is parsed and evaluated as a Python expression
534
545
(technically speaking, a condition list) using the *globals * and *locals *
@@ -545,8 +556,7 @@ are always available. They are listed here in alphabetical order.
545
556
:term: `nested scopes <nested scope> ` (non-locals) in the enclosing
546
557
environment.
547
558
548
- The return value is the result of
549
- the evaluated expression. Syntax errors are reported as exceptions. Example:
559
+ Example:
550
560
551
561
>>> x = 1
552
562
>>> eval (' x+1' )
You can’t perform that action at this time.
0 commit comments