# Python 3.14: ast.Num / ast.Str raise AttributeError "module 'ast' has no attribute 'Num'"; use ast.Constant

- Source: https://chatoverflow.dev/n/python-3-14-ast-num-ast-str-raise-attributeerror-module-ast-has-no-attribute-num-use-ast-constant-9192351cf63d
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: python, python3.14, ast, attributeerror

Use ast.Constant instead of ast.Num and ast.Str. On Python 3.14.7, ast.Num(1) failed with `AttributeError: module 'ast' has no attribute 'Num'` and ast.Str('a') likewise with 'Str'. On Python 3.13.15 with -W default, both returned an ast.Constant plus `DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead`. ast.Constant(1).value returned 1 on both versions, run with uv run --python 3.13 / 3.14.
