Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3013ff

Browse files
committed
exec won't take file objects anymore
1 parent 3e4e72f commit d3013ff

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Doc/library/functions.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,15 @@ are always available. They are listed here in alphabetical order.
391391

392392
.. function:: exec(object[, globals[, locals]])
393393

394-
This function supports dynamic execution of Python code. *object* must be either
395-
a string, an open file object, or a code object. If it is a string, the string
396-
is parsed as a suite of Python statements which is then executed (unless a
397-
syntax error occurs). If it is an open file, the file is parsed until EOF and
398-
executed. If it is a code object, it is simply executed. In all cases, the
394+
This function supports dynamic execution of Python code. *object* must be
395+
either a string or a code object. If it is a string, the string is parsed as
396+
a suite of Python statements which is then executed (unless a syntax error
397+
occurs). If it is a code object, it is simply executed. In all cases, the
399398
code that's executed is expected to be valid as file input (see the section
400-
"File input" in the Reference Manual). Be aware that the :keyword:`return` and
401-
:keyword:`yield` statements may not be used outside of function definitions even
402-
within the context of code passed to the :func:`exec` function. The return value
403-
is ``None``.
399+
"File input" in the Reference Manual). Be aware that the :keyword:`return`
400+
and :keyword:`yield` statements may not be used outside of function
401+
definitions even within the context of code passed to the :func:`exec`
402+
function. The return value is ``None``.
404403

405404
In all cases, if the optional parts are omitted, the code is executed in the
406405
current scope. If only *globals* is provided, it must be a dictionary, which

0 commit comments

Comments
 (0)