@@ -274,18 +274,25 @@ Root nodes
274274Literals
275275^^^^^^^^
276276
277- .. class :: Constant(value)
277+ .. class :: Constant(value, kind )
278278
279279 A constant value. The ``value `` attribute of the ``Constant `` literal contains the
280280 Python object it represents. The values represented can be instances of :class: `str `,
281281 :class: `bytes `, :class: `int `, :class: `float `, :class: `complex `, and :class: `bool `,
282282 and the constants :data: `None ` and :data: `Ellipsis `.
283283
284+ The ``kind `` attribute is an optional string. For string literals with a
285+ ``u `` prefix, ``kind `` is set to ``'u' ``. For all other
286+ constants, ``kind `` is ``None ``.
287+
284288 .. doctest ::
285289
286290 >>> print (ast.dump(ast.parse(' 123' , mode = ' eval' ), indent = 4 ))
287291 Expression(
288292 body=Constant(value=123))
293+ >>> print (ast.dump(ast.parse(" u'hello'" , mode = ' eval' ), indent = 4 ))
294+ Expression(
295+ body=Constant(value='hello', kind='u'))
289296
290297
291298.. class :: FormattedValue(value, conversion, format_spec)
@@ -2549,6 +2556,20 @@ and classes for traversing abstract syntax trees:
25492556 type_ignores=[])
25502557
25512558
2559+ .. function :: compare(a, b, /, *, compare_attributes=False)
2560+
2561+ Recursively compares two ASTs.
2562+
2563+ *compare_attributes * affects whether AST attributes are considered
2564+ in the comparison. If *compare_attributes * is ``False `` (default), then
2565+ attributes are ignored. Otherwise they must all be equal. This
2566+ option is useful to check whether the ASTs are structurally equal but
2567+ differ in whitespace or similar details. Attributes include line numbers
2568+ and column offsets.
2569+
2570+ .. versionadded :: 3.14
2571+
2572+
25522573.. _ast-compiler-flags :
25532574
25542575Compiler flags
@@ -2584,20 +2605,6 @@ effects on the compilation of a program:
25842605 .. versionadded :: 3.8
25852606
25862607
2587- .. function :: compare(a, b, /, *, compare_attributes=False)
2588-
2589- Recursively compares two ASTs.
2590-
2591- *compare_attributes * affects whether AST attributes are considered
2592- in the comparison. If *compare_attributes * is ``False `` (default), then
2593- attributes are ignored. Otherwise they must all be equal. This
2594- option is useful to check whether the ASTs are structurally equal but
2595- differ in whitespace or similar details. Attributes include line numbers
2596- and column offsets.
2597-
2598- .. versionadded :: 3.14
2599-
2600-
26012608.. _ast-cli :
26022609
26032610Command-line usage
0 commit comments