Skip to content
Merged
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
9 changes: 8 additions & 1 deletion Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,25 @@ Root nodes
Literals
^^^^^^^^

.. class:: Constant(value)
.. class:: Constant(value, kind)

A constant value. The ``value`` attribute of the ``Constant`` literal contains the
Python object it represents. The values represented can be instances of :class:`str`,
:class:`bytes`, :class:`int`, :class:`float`, :class:`complex`, and :class:`bool`,
and the constants :data:`None` and :data:`Ellipsis`.

The ``kind`` attribute is an optional string. For string literals with a
``u`` prefix, ``kind`` is set to ``'u'``. For all other
constants, ``kind`` is ``None``.

.. doctest::

>>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
Expression(
body=Constant(value=123))
>>> print(ast.dump(ast.parse("u'hello'", mode='eval'), indent=4))
Expression(
body=Constant(value='hello', kind='u'))


.. class:: FormattedValue(value, conversion, format_spec)
Expand Down
Loading