Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
symtable.html812 linesDownload Raw Back to docs
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4  <head>5    <meta charset="utf-8" />6    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="symtable — Access to the compiler’s symbol tables" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/symtable.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="Source code: Lib/symtable.py Symbol tables are generated by the compiler from AST just before bytecode is generated. The symbol table is responsible for calculating the scope of every identifier in..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_symtable_eb02ee07.png" />15<meta property="og:image:alt" content="Source code: Lib/symtable.py Symbol tables are generated by the compiler from AST just before bytecode is generated. The symbol table is responsible for calculating the scope of every identifier in..." />16<meta name="description" content="Source code: Lib/symtable.py Symbol tables are generated by the compiler from AST just before bytecode is generated. The symbol table is responsible for calculating the scope of every identifier in..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>symtable — Access to the compiler’s symbol tables &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21    22    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27    28    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29    <script src="../_static/doctools.js?v=9bcbadda"></script>30    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32    33    <script src="../_static/sidebar.js"></script>34    35    <link rel="search" type="application/opensearchdescription+xml"36          title="Search within Python 3.15.0a6 documentation"37          href="../_static/opensearch.xml"/>38    <link rel="author" title="About these documents" href="../about.html" />39    <link rel="index" title="Index" href="../genindex.html" />40    <link rel="search" title="Search" href="../search.html" />41    <link rel="copyright" title="Copyright" href="../copyright.html" />42    <link rel="next" title="token — Constants used with Python parse trees" href="token.html" />43    <link rel="prev" title="ast — Abstract syntax trees" href="ast.html" />44    45      46      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47      48      <link rel="canonical" href="https://docs.python.org/3/library/symtable.html">49      50    51 52    53    <style>54      @media only screen {55        table.full-width-table {56            width: 100%;57        }58      }59    </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62            <script type="text/javascript" src="../_static/copybutton.js"></script>63            <script type="text/javascript" src="../_static/menu.js"></script>64            <script type="text/javascript" src="../_static/search-focus.js"></script>65            <script type="text/javascript" src="../_static/themetoggle.js"></script> 66            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67            <meta name="readthedocs-addons-api-version" content="1">68 69  </head>70<body>71<div class="mobile-nav">72    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74    <nav class="nav-content" role="navigation">75        <label for="menuToggler" class="toggler__label">76            <span></span>77        </label>78        <span class="nav-items-wrapper">79            <a href="https://www.python.org/" class="nav-logo">80                <img src="../_static/py.svg" alt="Python logo">81            </a>82            <span class="version_switcher_placeholder"></span>83            <form role="search" class="search" action="../search.html" method="get">84                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86                </svg>87                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88                <input type="submit" value="Go">89            </form>90        </span>91    </nav>92    <div class="menu-wrapper">93        <nav class="menu" role="navigation" aria-label="main navigation">94            <div class="language_switcher_placeholder"></div>95            96<label class="theme-selector-label">97    Theme98    <select class="theme-selector" oninput="activateTheme(this.value)">99        <option value="auto" selected>Auto</option>100        <option value="light">Light</option>101        <option value="dark">Dark</option>102    </select>103</label>104  <div>105    <h3><a href="../contents.html">Table of Contents</a></h3>106    <ul>107<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code> — Access to the compiler’s symbol tables</a><ul>108<li><a class="reference internal" href="#generating-symbol-tables">Generating Symbol Tables</a></li>109<li><a class="reference internal" href="#examining-symbol-tables">Examining Symbol Tables</a></li>110<li><a class="reference internal" href="#command-line-usage">Command-Line Usage</a></li>111</ul>112</li>113</ul>114 115  </div>116  <div>117    <h4>Previous topic</h4>118    <p class="topless"><a href="ast.html"119                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ast</span></code> — Abstract syntax trees</a></p>120  </div>121  <div>122    <h4>Next topic</h4>123    <p class="topless"><a href="token.html"124                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">token</span></code> — Constants used with Python parse trees</a></p>125  </div>126  <script>127    document.addEventListener('DOMContentLoaded', () => {128        const title = document.querySelector('meta[property="og:title"]').content;129        const elements = document.querySelectorAll('.improvepage');130        const pageurl = window.location.href.split('?')[0];131        elements.forEach(element => {132            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));133            url.searchParams.set('pagetitle', title);134            url.searchParams.set('pageurl', pageurl);135            url.searchParams.set('pagesource', "library/symtable.rst");136            element.href = url.toString();137        });138    });139  </script>140  <div role="note" aria-label="source link">141    <h3>This page</h3>142    <ul class="this-page-menu">143      <li><a href="../bugs.html">Report a bug</a></li>144      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>145      <li>146        <a href="https://github.com/python/cpython/blob/main/Doc/library/symtable.rst?plain=1"147            rel="nofollow">Show source148        </a>149      </li>150      151    </ul>152  </div>153        </nav>154    </div>155</div>156 157  158    <div class="related" role="navigation" aria-label="Related">159      <h3>Navigation</h3>160      <ul>161        <li class="right" style="margin-right: 10px">162          <a href="../genindex.html" title="General Index"163             accesskey="I">index</a></li>164        <li class="right" >165          <a href="../py-modindex.html" title="Python Module Index"166             >modules</a> |</li>167        <li class="right" >168          <a href="token.html" title="token — Constants used with Python parse trees"169             accesskey="N">next</a> |</li>170        <li class="right" >171          <a href="ast.html" title="ast — Abstract syntax trees"172             accesskey="P">previous</a> |</li>173 174          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>175          <li><a href="https://www.python.org/">Python</a> &#187;</li>176          <li class="switchers">177            <div class="language_switcher_placeholder"></div>178            <div class="version_switcher_placeholder"></div>179          </li>180          <li>181              182          </li>183    <li id="cpython-language-and-version">184      <a href="../index.html">3.15.0a6 Documentation</a> &#187;185    </li>186 187          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>188          <li class="nav-item nav-item-2"><a href="language.html" accesskey="U">Python Language Services</a> &#187;</li>189        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code> — Access to the compiler’s symbol tables</a></li>190                <li class="right">191                    192 193    <div class="inline-search" role="search">194        <form class="inline-search" action="../search.html" method="get">195          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">196          <input type="submit" value="Go">197        </form>198    </div>199                     |200                </li>201            <li class="right">202<label class="theme-selector-label">203    Theme204    <select class="theme-selector" oninput="activateTheme(this.value)">205        <option value="auto" selected>Auto</option>206        <option value="light">Light</option>207        <option value="dark">Dark</option>208    </select>209</label> |</li>210            211      </ul>212    </div>    213 214    <div class="document">215      <div class="documentwrapper">216        <div class="bodywrapper">217          <div class="body" role="main">218            219  <section id="module-symtable">220<span id="symtable-access-to-the-compiler-s-symbol-tables"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code> — Access to the compiler’s symbol tables<a class="headerlink" href="#module-symtable" title="Link to this heading">¶</a></h1>221<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/symtable.py">Lib/symtable.py</a></p>222<hr class="docutils" />223<p>Symbol tables are generated by the compiler from AST just before bytecode is224generated.  The symbol table is responsible for calculating the scope of every225identifier in the code.  <code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code> provides an interface to examine these226tables.</p>227<section id="generating-symbol-tables">228<h2>Generating Symbol Tables<a class="headerlink" href="#generating-symbol-tables" title="Link to this heading">¶</a></h2>229<dl class="py function">230<dt class="sig sig-object py" id="symtable.symtable">231<span class="sig-prename descclassname"><span class="pre">symtable.</span></span><span class="sig-name descname"><span class="pre">symtable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compile_type</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">module</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#symtable.symtable" title="Link to this definition">¶</a></dt>232<dd><p>Return the toplevel <a class="reference internal" href="#symtable.SymbolTable" title="symtable.SymbolTable"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTable</span></code></a> for the Python source <em>code</em>.233<em>filename</em> is the name of the file containing the code.  <em>compile_type</em> is234like the <em>mode</em> argument to <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a>.235The optional argument <em>module</em> specifies the module name.236It is needed to unambiguous <a class="reference internal" href="warnings.html#warning-filter"><span class="std std-ref">filter</span></a> syntax warnings237by module name.</p>238<div class="versionadded">239<p><span class="versionmodified added">Added in version 3.15: </span>Added the <em>module</em> parameter.</p>240</div>241</dd></dl>242 243</section>244<section id="examining-symbol-tables">245<h2>Examining Symbol Tables<a class="headerlink" href="#examining-symbol-tables" title="Link to this heading">¶</a></h2>246<dl class="py class">247<dt class="sig sig-object py" id="symtable.SymbolTableType">248<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">symtable.</span></span><span class="sig-name descname"><span class="pre">SymbolTableType</span></span><a class="headerlink" href="#symtable.SymbolTableType" title="Link to this definition">¶</a></dt>249<dd><p>An enumeration indicating the type of a <a class="reference internal" href="#symtable.SymbolTable" title="symtable.SymbolTable"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTable</span></code></a> object.</p>250<dl class="py attribute">251<dt class="sig sig-object py" id="symtable.SymbolTableType.MODULE">252<span class="sig-name descname"><span class="pre">MODULE</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&quot;module&quot;</span></em><a class="headerlink" href="#symtable.SymbolTableType.MODULE" title="Link to this definition">¶</a></dt>253<dd><p>Used for the symbol table of a module.</p>254</dd></dl>255 256<dl class="py attribute">257<dt class="sig sig-object py" id="symtable.SymbolTableType.FUNCTION">258<span class="sig-name descname"><span class="pre">FUNCTION</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&quot;function&quot;</span></em><a class="headerlink" href="#symtable.SymbolTableType.FUNCTION" title="Link to this definition">¶</a></dt>259<dd><p>Used for the symbol table of a function.</p>260</dd></dl>261 262<dl class="py attribute">263<dt class="sig sig-object py" id="symtable.SymbolTableType.CLASS">264<span class="sig-name descname"><span class="pre">CLASS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&quot;class&quot;</span></em><a class="headerlink" href="#symtable.SymbolTableType.CLASS" title="Link to this definition">¶</a></dt>265<dd><p>Used for the symbol table of a class.</p>266</dd></dl>267 268<p>The following members refer to different flavors of269<a class="reference internal" href="../reference/executionmodel.html#annotation-scopes"><span class="std std-ref">annotation scopes</span></a>.</p>270<dl class="py attribute">271<dt class="sig sig-object py" id="symtable.SymbolTableType.ANNOTATION">272<span class="sig-name descname"><span class="pre">ANNOTATION</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&quot;annotation&quot;</span></em><a class="headerlink" href="#symtable.SymbolTableType.ANNOTATION" title="Link to this definition">¶</a></dt>273<dd><p>Used for annotations if <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">__future__</span> <span class="pre">import</span> <span class="pre">annotations</span></code> is active.</p>274</dd></dl>275 276<dl class="py attribute">277<dt class="sig sig-object py" id="symtable.SymbolTableType.TYPE_ALIAS">278<span class="sig-name descname"><span class="pre">TYPE_ALIAS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&quot;type</span> <span class="pre">alias&quot;</span></em><a class="headerlink" href="#symtable.SymbolTableType.TYPE_ALIAS" title="Link to this definition">¶</a></dt>279<dd><p>Used for the symbol table of <a class="reference internal" href="../reference/simple_stmts.html#type"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">type</span></code></a> constructions.</p>280</dd></dl>281 282<dl class="py attribute">283<dt class="sig sig-object py" id="symtable.SymbolTableType.TYPE_PARAMETERS">284<span class="sig-name descname"><span class="pre">TYPE_PARAMETERS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&quot;type</span> <span class="pre">parameters&quot;</span></em><a class="headerlink" href="#symtable.SymbolTableType.TYPE_PARAMETERS" title="Link to this definition">¶</a></dt>285<dd><p>Used for the symbol table of <a class="reference internal" href="../reference/compound_stmts.html#generic-functions"><span class="std std-ref">generic functions</span></a>286or <a class="reference internal" href="../reference/compound_stmts.html#generic-classes"><span class="std std-ref">generic classes</span></a>.</p>287</dd></dl>288 289<dl class="py attribute">290<dt class="sig sig-object py" id="symtable.SymbolTableType.TYPE_VARIABLE">291<span class="sig-name descname"><span class="pre">TYPE_VARIABLE</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&quot;type</span> <span class="pre">variable&quot;</span></em><a class="headerlink" href="#symtable.SymbolTableType.TYPE_VARIABLE" title="Link to this definition">¶</a></dt>292<dd><p>Used for the symbol table of the bound, the constraint tuple or the293default value of a single type variable in the formal sense, i.e.,294a TypeVar, a TypeVarTuple or a ParamSpec object (the latter two do295not support a bound or a constraint tuple).</p>296</dd></dl>297 298<div class="versionadded">299<p><span class="versionmodified added">Added in version 3.13.</span></p>300</div>301</dd></dl>302 303<dl class="py class">304<dt class="sig sig-object py" id="symtable.SymbolTable">305<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">symtable.</span></span><span class="sig-name descname"><span class="pre">SymbolTable</span></span><a class="headerlink" href="#symtable.SymbolTable" title="Link to this definition">¶</a></dt>306<dd><p>A namespace table for a block.  The constructor is not public.</p>307<dl class="py method">308<dt class="sig sig-object py" id="symtable.SymbolTable.get_type">309<span class="sig-name descname"><span class="pre">get_type</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.get_type" title="Link to this definition">¶</a></dt>310<dd><p>Return the type of the symbol table.  Possible values are members311of the <a class="reference internal" href="#symtable.SymbolTableType" title="symtable.SymbolTableType"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTableType</span></code></a> enumeration.</p>312<div class="versionchanged">313<p><span class="versionmodified changed">Changed in version 3.12: </span>Added <code class="docutils literal notranslate"><span class="pre">'annotation'</span></code>,  <code class="docutils literal notranslate"><span class="pre">'TypeVar</span> <span class="pre">bound'</span></code>, <code class="docutils literal notranslate"><span class="pre">'type</span> <span class="pre">alias'</span></code>,314and <code class="docutils literal notranslate"><span class="pre">'type</span> <span class="pre">parameter'</span></code> as possible return values.</p>315</div>316<div class="versionchanged">317<p><span class="versionmodified changed">Changed in version 3.13: </span>Return values are members of the <a class="reference internal" href="#symtable.SymbolTableType" title="symtable.SymbolTableType"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTableType</span></code></a> enumeration.</p>318<p>The exact values of the returned string may change in the future,319and thus, it is recommended to use <a class="reference internal" href="#symtable.SymbolTableType" title="symtable.SymbolTableType"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTableType</span></code></a> members320instead of hard-coded strings.</p>321</div>322</dd></dl>323 324<dl class="py method">325<dt class="sig sig-object py" id="symtable.SymbolTable.get_id">326<span class="sig-name descname"><span class="pre">get_id</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.get_id" title="Link to this definition">¶</a></dt>327<dd><p>Return the table’s identifier.</p>328</dd></dl>329 330<dl class="py method">331<dt class="sig sig-object py" id="symtable.SymbolTable.get_name">332<span class="sig-name descname"><span class="pre">get_name</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.get_name" title="Link to this definition">¶</a></dt>333<dd><p>Return the table’s name.  This is the name of the class if the table is334for a class, the name of the function if the table is for a function, or335<code class="docutils literal notranslate"><span class="pre">'top'</span></code> if the table is global (<a class="reference internal" href="#symtable.SymbolTable.get_type" title="symtable.SymbolTable.get_type"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_type()</span></code></a> returns <code class="docutils literal notranslate"><span class="pre">'module'</span></code>).336For type parameter scopes (which are used for generic classes, functions,337and type aliases), it is the name of the underlying class, function, or338type alias. For type alias scopes, it is the name of the type alias.339For <a class="reference internal" href="typing.html#typing.TypeVar" title="typing.TypeVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TypeVar</span></code></a> bound scopes, it is the name of the <code class="docutils literal notranslate"><span class="pre">TypeVar</span></code>.</p>340</dd></dl>341 342<dl class="py method">343<dt class="sig sig-object py" id="symtable.SymbolTable.get_lineno">344<span class="sig-name descname"><span class="pre">get_lineno</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.get_lineno" title="Link to this definition">¶</a></dt>345<dd><p>Return the number of the first line in the block this table represents.</p>346</dd></dl>347 348<dl class="py method">349<dt class="sig sig-object py" id="symtable.SymbolTable.is_optimized">350<span class="sig-name descname"><span class="pre">is_optimized</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.is_optimized" title="Link to this definition">¶</a></dt>351<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the locals in this table can be optimized.</p>352</dd></dl>353 354<dl class="py method">355<dt class="sig sig-object py" id="symtable.SymbolTable.is_nested">356<span class="sig-name descname"><span class="pre">is_nested</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.is_nested" title="Link to this definition">¶</a></dt>357<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the block is a nested class or function.</p>358</dd></dl>359 360<dl class="py method">361<dt class="sig sig-object py" id="symtable.SymbolTable.has_children">362<span class="sig-name descname"><span class="pre">has_children</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.has_children" title="Link to this definition">¶</a></dt>363<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the block has nested namespaces within it.  These can364be obtained with <a class="reference internal" href="#symtable.SymbolTable.get_children" title="symtable.SymbolTable.get_children"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_children()</span></code></a>.</p>365</dd></dl>366 367<dl class="py method">368<dt class="sig sig-object py" id="symtable.SymbolTable.get_identifiers">369<span class="sig-name descname"><span class="pre">get_identifiers</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.get_identifiers" title="Link to this definition">¶</a></dt>370<dd><p>Return a view object containing the names of symbols in the table.371See the <a class="reference internal" href="stdtypes.html#dict-views"><span class="std std-ref">documentation of view objects</span></a>.</p>372</dd></dl>373 374<dl class="py method">375<dt class="sig sig-object py" id="symtable.SymbolTable.lookup">376<span class="sig-name descname"><span class="pre">lookup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.lookup" title="Link to this definition">¶</a></dt>377<dd><p>Lookup <em>name</em> in the table and return a <a class="reference internal" href="#symtable.Symbol" title="symtable.Symbol"><code class="xref py py-class docutils literal notranslate"><span class="pre">Symbol</span></code></a> instance.</p>378</dd></dl>379 380<dl class="py method">381<dt class="sig sig-object py" id="symtable.SymbolTable.get_symbols">382<span class="sig-name descname"><span class="pre">get_symbols</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.get_symbols" title="Link to this definition">¶</a></dt>383<dd><p>Return a list of <a class="reference internal" href="#symtable.Symbol" title="symtable.Symbol"><code class="xref py py-class docutils literal notranslate"><span class="pre">Symbol</span></code></a> instances for names in the table.</p>384</dd></dl>385 386<dl class="py method">387<dt class="sig sig-object py" id="symtable.SymbolTable.get_children">388<span class="sig-name descname"><span class="pre">get_children</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.SymbolTable.get_children" title="Link to this definition">¶</a></dt>389<dd><p>Return a list of the nested symbol tables.</p>390</dd></dl>391 392</dd></dl>393 394<dl class="py class">395<dt class="sig sig-object py" id="symtable.Function">396<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">symtable.</span></span><span class="sig-name descname"><span class="pre">Function</span></span><a class="headerlink" href="#symtable.Function" title="Link to this definition">¶</a></dt>397<dd><p>A namespace for a function or method.  This class inherits from398<a class="reference internal" href="#symtable.SymbolTable" title="symtable.SymbolTable"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTable</span></code></a>.</p>399<dl class="py method">400<dt class="sig sig-object py" id="symtable.Function.get_parameters">401<span class="sig-name descname"><span class="pre">get_parameters</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Function.get_parameters" title="Link to this definition">¶</a></dt>402<dd><p>Return a tuple containing names of parameters to this function.</p>403</dd></dl>404 405<dl class="py method">406<dt class="sig sig-object py" id="symtable.Function.get_locals">407<span class="sig-name descname"><span class="pre">get_locals</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Function.get_locals" title="Link to this definition">¶</a></dt>408<dd><p>Return a tuple containing names of locals in this function.</p>409</dd></dl>410 411<dl class="py method">412<dt class="sig sig-object py" id="symtable.Function.get_globals">413<span class="sig-name descname"><span class="pre">get_globals</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Function.get_globals" title="Link to this definition">¶</a></dt>414<dd><p>Return a tuple containing names of globals in this function.</p>415</dd></dl>416 417<dl class="py method">418<dt class="sig sig-object py" id="symtable.Function.get_nonlocals">419<span class="sig-name descname"><span class="pre">get_nonlocals</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Function.get_nonlocals" title="Link to this definition">¶</a></dt>420<dd><p>Return a tuple containing names of explicitly declared nonlocals in this function.</p>421</dd></dl>422 423<dl class="py method">424<dt class="sig sig-object py" id="symtable.Function.get_frees">425<span class="sig-name descname"><span class="pre">get_frees</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Function.get_frees" title="Link to this definition">¶</a></dt>426<dd><p>Return a tuple containing names of <a class="reference internal" href="../glossary.html#term-closure-variable"><span class="xref std std-term">free (closure) variables</span></a>427in this function.</p>428</dd></dl>429 430<dl class="py method">431<dt class="sig sig-object py" id="symtable.Function.get_cells">432<span class="sig-name descname"><span class="pre">get_cells</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Function.get_cells" title="Link to this definition">¶</a></dt>433<dd><p>Return a tuple containing names of <a class="reference internal" href="../glossary.html#term-closure-variable"><span class="xref std std-term">cell variables</span></a> in this table.</p>434<div class="versionadded">435<p><span class="versionmodified added">Added in version 3.15.</span></p>436</div>437</dd></dl>438 439</dd></dl>440 441<dl class="py class">442<dt class="sig sig-object py" id="symtable.Class">443<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">symtable.</span></span><span class="sig-name descname"><span class="pre">Class</span></span><a class="headerlink" href="#symtable.Class" title="Link to this definition">¶</a></dt>444<dd><p>A namespace of a class.  This class inherits from <a class="reference internal" href="#symtable.SymbolTable" title="symtable.SymbolTable"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTable</span></code></a>.</p>445<dl class="py method">446<dt class="sig sig-object py" id="symtable.Class.get_methods">447<span class="sig-name descname"><span class="pre">get_methods</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Class.get_methods" title="Link to this definition">¶</a></dt>448<dd><p>Return a tuple containing the names of method-like functions declared449in the class.</p>450<p>Here, the term ‘method’ designates <em>any</em> function defined in the class451body via <a class="reference internal" href="../reference/compound_stmts.html#def"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">def</span></code></a> or <a class="reference internal" href="../reference/compound_stmts.html#async-def"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">def</span></code></a>.</p>452<p>Functions defined in a deeper scope (e.g., in an inner class) are not453picked up by <code class="xref py py-meth docutils literal notranslate"><span class="pre">get_methods()</span></code>.</p>454<p>For example:</p>455<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">symtable</span>456<span class="gp">&gt;&gt;&gt; </span><span class="n">st</span> <span class="o">=</span> <span class="n">symtable</span><span class="o">.</span><span class="n">symtable</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>457<span class="gp">... </span><span class="s1">def outer(): pass</span>458<span class="gp">...</span>459<span class="gp">... </span><span class="s1">class A:</span>460<span class="gp">... </span><span class="s1">   def f():</span>461<span class="gp">... </span><span class="s1">       def w(): pass</span>462<span class="gp">...</span>463<span class="gp">... </span><span class="s1">   def g(self): pass</span>464<span class="gp">...</span>465<span class="gp">... </span><span class="s1">   @classmethod</span>466<span class="gp">... </span><span class="s1">   async def h(cls): pass</span>467<span class="gp">...</span>468<span class="gp">... </span><span class="s1">   global outer</span>469<span class="gp">... </span><span class="s1">   def outer(self): pass</span>470<span class="gp">... </span><span class="s1">&#39;&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="s1">&#39;exec&#39;</span><span class="p">)</span>471<span class="gp">&gt;&gt;&gt; </span><span class="n">class_A</span> <span class="o">=</span> <span class="n">st</span><span class="o">.</span><span class="n">get_children</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span>472<span class="gp">&gt;&gt;&gt; </span><span class="n">class_A</span><span class="o">.</span><span class="n">get_methods</span><span class="p">()</span>473<span class="go">(&#39;f&#39;, &#39;g&#39;, &#39;h&#39;)</span>474</pre></div>475</div>476<p>Although <code class="docutils literal notranslate"><span class="pre">A().f()</span></code> raises <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> at runtime, <code class="docutils literal notranslate"><span class="pre">A.f</span></code> is still477considered as a method-like function.</p>478<div class="deprecated-removed">479<p><span class="versionmodified deprecated">Deprecated since version 3.14, will be removed in version 3.16.</span></p>480</div>481</dd></dl>482 483</dd></dl>484 485<dl class="py class">486<dt class="sig sig-object py" id="symtable.Symbol">487<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">symtable.</span></span><span class="sig-name descname"><span class="pre">Symbol</span></span><a class="headerlink" href="#symtable.Symbol" title="Link to this definition">¶</a></dt>488<dd><p>An entry in a <a class="reference internal" href="#symtable.SymbolTable" title="symtable.SymbolTable"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolTable</span></code></a> corresponding to an identifier in the489source.  The constructor is not public.</p>490<dl class="py method">491<dt class="sig sig-object py" id="symtable.Symbol.get_name">492<span class="sig-name descname"><span class="pre">get_name</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.get_name" title="Link to this definition">¶</a></dt>493<dd><p>Return the symbol’s name.</p>494</dd></dl>495 496<dl class="py method">497<dt class="sig sig-object py" id="symtable.Symbol.is_referenced">498<span class="sig-name descname"><span class="pre">is_referenced</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_referenced" title="Link to this definition">¶</a></dt>499<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is used in its block.</p>500</dd></dl>501 502<dl class="py method">503<dt class="sig sig-object py" id="symtable.Symbol.is_imported">504<span class="sig-name descname"><span class="pre">is_imported</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_imported" title="Link to this definition">¶</a></dt>505<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is created from an import statement.</p>506</dd></dl>507 508<dl class="py method">509<dt class="sig sig-object py" id="symtable.Symbol.is_parameter">510<span class="sig-name descname"><span class="pre">is_parameter</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_parameter" title="Link to this definition">¶</a></dt>511<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is a parameter.</p>512</dd></dl>513 514<dl class="py method">515<dt class="sig sig-object py" id="symtable.Symbol.is_type_parameter">516<span class="sig-name descname"><span class="pre">is_type_parameter</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_type_parameter" title="Link to this definition">¶</a></dt>517<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is a type parameter.</p>518<div class="versionadded">519<p><span class="versionmodified added">Added in version 3.14.</span></p>520</div>521</dd></dl>522 523<dl class="py method">524<dt class="sig sig-object py" id="symtable.Symbol.is_global">525<span class="sig-name descname"><span class="pre">is_global</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_global" title="Link to this definition">¶</a></dt>526<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is global.</p>527</dd></dl>528 529<dl class="py method">530<dt class="sig sig-object py" id="symtable.Symbol.is_nonlocal">531<span class="sig-name descname"><span class="pre">is_nonlocal</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_nonlocal" title="Link to this definition">¶</a></dt>532<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is nonlocal.</p>533</dd></dl>534 535<dl class="py method">536<dt class="sig sig-object py" id="symtable.Symbol.is_declared_global">537<span class="sig-name descname"><span class="pre">is_declared_global</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_declared_global" title="Link to this definition">¶</a></dt>538<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is declared global with a global statement.</p>539</dd></dl>540 541<dl class="py method">542<dt class="sig sig-object py" id="symtable.Symbol.is_local">543<span class="sig-name descname"><span class="pre">is_local</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_local" title="Link to this definition">¶</a></dt>544<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is local to its block.</p>545</dd></dl>546 547<dl class="py method">548<dt class="sig sig-object py" id="symtable.Symbol.is_annotated">549<span class="sig-name descname"><span class="pre">is_annotated</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_annotated" title="Link to this definition">¶</a></dt>550<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is annotated.</p>551<div class="versionadded">552<p><span class="versionmodified added">Added in version 3.6.</span></p>553</div>554</dd></dl>555 556<dl class="py method">557<dt class="sig sig-object py" id="symtable.Symbol.is_free">558<span class="sig-name descname"><span class="pre">is_free</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_free" title="Link to this definition">¶</a></dt>559<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is referenced in its block, but not assigned560to.</p>561</dd></dl>562 563<dl class="py method">564<dt class="sig sig-object py" id="symtable.Symbol.is_cell">565<span class="sig-name descname"><span class="pre">is_cell</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_cell" title="Link to this definition">¶</a></dt>566<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is referenced but not assigned in a nested block.</p>567<div class="versionadded">568<p><span class="versionmodified added">Added in version 3.15.</span></p>569</div>570</dd></dl>571 572<dl class="py method">573<dt class="sig sig-object py" id="symtable.Symbol.is_free_class">574<span class="sig-name descname"><span class="pre">is_free_class</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_free_class" title="Link to this definition">¶</a></dt>575<dd><p>Return <em>True</em> if a class-scoped symbol is free from576the perspective of a method.</p>577<p>Consider the following example:</p>578<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">f</span><span class="p">():</span>579    <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span>  <span class="c1"># function-scoped</span>580    <span class="k">class</span><span class="w"> </span><span class="nc">C</span><span class="p">:</span>581        <span class="n">x</span> <span class="o">=</span> <span class="mi">2</span>  <span class="c1"># class-scoped</span>582        <span class="k">def</span><span class="w"> </span><span class="nf">method</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>583            <span class="k">return</span> <span class="n">x</span>584</pre></div>585</div>586<p>In this example, the class-scoped symbol <code class="docutils literal notranslate"><span class="pre">x</span></code> is considered to587be free from the perspective of <code class="docutils literal notranslate"><span class="pre">C.method</span></code>, thereby allowing588the latter to return <em>1</em> at runtime and not <em>2</em>.</p>589<div class="versionadded">590<p><span class="versionmodified added">Added in version 3.14.</span></p>591</div>592</dd></dl>593 594<dl class="py method">595<dt class="sig sig-object py" id="symtable.Symbol.is_assigned">596<span class="sig-name descname"><span class="pre">is_assigned</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_assigned" title="Link to this definition">¶</a></dt>597<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is assigned to in its block.</p>598</dd></dl>599 600<dl class="py method">601<dt class="sig sig-object py" id="symtable.Symbol.is_comp_iter">602<span class="sig-name descname"><span class="pre">is_comp_iter</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_comp_iter" title="Link to this definition">¶</a></dt>603<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is a comprehension iteration variable.</p>604<div class="versionadded">605<p><span class="versionmodified added">Added in version 3.14.</span></p>606</div>607</dd></dl>608 609<dl class="py method">610<dt class="sig sig-object py" id="symtable.Symbol.is_comp_cell">611<span class="sig-name descname"><span class="pre">is_comp_cell</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_comp_cell" title="Link to this definition">¶</a></dt>612<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the symbol is a cell in an inlined comprehension.</p>613<div class="versionadded">614<p><span class="versionmodified added">Added in version 3.14.</span></p>615</div>616</dd></dl>617 618<dl class="py method">619<dt class="sig sig-object py" id="symtable.Symbol.is_namespace">620<span class="sig-name descname"><span class="pre">is_namespace</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.is_namespace" title="Link to this definition">¶</a></dt>621<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if name binding introduces new namespace.</p>622<p>If the name is used as the target of a function or class statement, this623will be true.</p>624<p>For example:</p>625<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">table</span> <span class="o">=</span> <span class="n">symtable</span><span class="o">.</span><span class="n">symtable</span><span class="p">(</span><span class="s2">&quot;def some_func(): pass&quot;</span><span class="p">,</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span> <span class="s2">&quot;exec&quot;</span><span class="p">)</span>626<span class="gp">&gt;&gt;&gt; </span><span class="n">table</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s2">&quot;some_func&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">is_namespace</span><span class="p">()</span>627<span class="go">True</span>628</pre></div>629</div>630<p>Note that a single name can be bound to multiple objects.  If the result631is <code class="docutils literal notranslate"><span class="pre">True</span></code>, the name may also be bound to other objects, like an int or632list, that does not introduce a new namespace.</p>633</dd></dl>634 635<dl class="py method">636<dt class="sig sig-object py" id="symtable.Symbol.get_namespaces">637<span class="sig-name descname"><span class="pre">get_namespaces</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.get_namespaces" title="Link to this definition">¶</a></dt>638<dd><p>Return a list of namespaces bound to this name.</p>639</dd></dl>640 641<dl class="py method">642<dt class="sig sig-object py" id="symtable.Symbol.get_namespace">643<span class="sig-name descname"><span class="pre">get_namespace</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#symtable.Symbol.get_namespace" title="Link to this definition">¶</a></dt>644<dd><p>Return the namespace bound to this name. If more than one or no namespace645is bound to this name, a <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised.</p>646</dd></dl>647 648</dd></dl>649 650</section>651<section id="command-line-usage">652<span id="symtable-cli"></span><h2>Command-Line Usage<a class="headerlink" href="#command-line-usage" title="Link to this heading">¶</a></h2>653<div class="versionadded">654<p><span class="versionmodified added">Added in version 3.13.</span></p>655</div>656<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code> module can be executed as a script from the command line.</p>657<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>symtable<span class="w"> </span><span class="o">[</span>infile...<span class="o">]</span>658</pre></div>659</div>660<p>Symbol tables are generated for the specified Python source files and661dumped to stdout.662If no input file is specified, the content is read from stdin.</p>663</section>664</section>665 666 667            <div class="clearer"></div>668          </div>669        </div>670      </div>671      <div class="sphinxsidebar" role="navigation" aria-label="Main">672        <div class="sphinxsidebarwrapper">673  <div>674    <h3><a href="../contents.html">Table of Contents</a></h3>675    <ul>676<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code> — Access to the compiler’s symbol tables</a><ul>677<li><a class="reference internal" href="#generating-symbol-tables">Generating Symbol Tables</a></li>678<li><a class="reference internal" href="#examining-symbol-tables">Examining Symbol Tables</a></li>679<li><a class="reference internal" href="#command-line-usage">Command-Line Usage</a></li>680</ul>681</li>682</ul>683 684  </div>685  <div>686    <h4>Previous topic</h4>687    <p class="topless"><a href="ast.html"688                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ast</span></code> — Abstract syntax trees</a></p>689  </div>690  <div>691    <h4>Next topic</h4>692    <p class="topless"><a href="token.html"693                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">token</span></code> — Constants used with Python parse trees</a></p>694  </div>695  <script>696    document.addEventListener('DOMContentLoaded', () => {697        const title = document.querySelector('meta[property="og:title"]').content;698        const elements = document.querySelectorAll('.improvepage');699        const pageurl = window.location.href.split('?')[0];700        elements.forEach(element => {701            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));702            url.searchParams.set('pagetitle', title);703            url.searchParams.set('pageurl', pageurl);704            url.searchParams.set('pagesource', "library/symtable.rst");705            element.href = url.toString();706        });707    });708  </script>709  <div role="note" aria-label="source link">710    <h3>This page</h3>711    <ul class="this-page-menu">712      <li><a href="../bugs.html">Report a bug</a></li>713      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>714      <li>715        <a href="https://github.com/python/cpython/blob/main/Doc/library/symtable.rst?plain=1"716            rel="nofollow">Show source717        </a>718      </li>719      720    </ul>721  </div>722        </div>723<div id="sidebarbutton" title="Collapse sidebar">724<span>«</span>725</div>726 727      </div>728      <div class="clearer"></div>729    </div>  730    <div class="related" role="navigation" aria-label="Related">731      <h3>Navigation</h3>732      <ul>733        <li class="right" style="margin-right: 10px">734          <a href="../genindex.html" title="General Index"735             >index</a></li>736        <li class="right" >737          <a href="../py-modindex.html" title="Python Module Index"738             >modules</a> |</li>739        <li class="right" >740          <a href="token.html" title="token — Constants used with Python parse trees"741             >next</a> |</li>742        <li class="right" >743          <a href="ast.html" title="ast — Abstract syntax trees"744             >previous</a> |</li>745 746          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>747          <li><a href="https://www.python.org/">Python</a> &#187;</li>748          <li class="switchers">749            <div class="language_switcher_placeholder"></div>750            <div class="version_switcher_placeholder"></div>751          </li>752          <li>753              754          </li>755    <li id="cpython-language-and-version">756      <a href="../index.html">3.15.0a6 Documentation</a> &#187;757    </li>758 759          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>760          <li class="nav-item nav-item-2"><a href="language.html" >Python Language Services</a> &#187;</li>761        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code> — Access to the compiler’s symbol tables</a></li>762                <li class="right">763                    764 765    <div class="inline-search" role="search">766        <form class="inline-search" action="../search.html" method="get">767          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">768          <input type="submit" value="Go">769        </form>770    </div>771                     |772                </li>773            <li class="right">774<label class="theme-selector-label">775    Theme776    <select class="theme-selector" oninput="activateTheme(this.value)">777        <option value="auto" selected>Auto</option>778        <option value="light">Light</option>779        <option value="dark">Dark</option>780    </select>781</label> |</li>782            783      </ul>784    </div>  785    <div class="footer">786    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.787    <br>788    This page is licensed under the Python Software Foundation License Version 2.789    <br>790    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.791    <br>792    793      See <a href="/license.html">History and License</a> for more information.<br>794    795    796    <br>797 798    The Python Software Foundation is a non-profit corporation.799<a href="https://www.python.org/psf/donations/">Please donate.</a>800<br>801    <br>802      Last updated on Mar 10, 2026 (08:58 UTC).803    804      <a href="/bugs.html">Found a bug</a>?805    806    <br>807 808    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.809    </div>810 811  </body>812</html>