Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,14 @@ are always available. They are listed here in alphabetical order.
pass some recognizable value if it wasn't read from a file (``'<string>'`` is
commonly used).

The *mode* argument specifies what kind of code must be compiled; it can be
``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if it
consists of a single expression, or ``'single'`` if it consists of a single
interactive statement (in the latter case, expression statements that
evaluate to something other than ``None`` will be printed).
The *mode* argument specifies what kind of code must be compiled; it can be:
- ``'exec'`` if *source* consists of a sequence of statements. If the first
statement is a string literal it will be interpreted as a module
docstring.
- ``'eval'`` if *source* consists of a single expression.
- ``'single'`` if *source* consists of a single interactive statement. In
this mode, expression statements that evaluate to something other than ``None``
will be printed).

The optional arguments *flags* and *dont_inherit* control which future
statements (see :pep:`236`) affect the compilation of *source*. If neither
Expand Down Expand Up @@ -288,6 +291,11 @@ are always available. They are listed here in alphabetical order.
Previously, :exc:`TypeError` was raised when null bytes were encountered
in *source*.

.. versionchanged:: 3.7
In ``exec`` **mode**, if the first statement is a string literal it will
be interpreted as a module docstring, and assigned to the ``Module``
**docstring** field instead of being the first **body** node.


.. class:: complex([real[, imag]])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve builtin's compile documentation.