blob: 81fc8059966ccbc1314d078550c3e83d88468b30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<span id="keyword-testing-for-python-keywords"></span><h1>keyword — Testing for Python keywords</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/keyword.py">Lib/keyword.py</a></p> <p>This module allows a Python program to determine if a string is a <a class="reference internal" href="../reference/lexical_analysis#keywords"><span class="std std-ref">keyword</span></a> or <a class="reference internal" href="../reference/lexical_analysis#soft-keywords"><span class="std std-ref">soft keyword</span></a>.</p> <dl class="py function"> <dt class="sig sig-object py" id="keyword.iskeyword">
<code>keyword.iskeyword(s)</code> </dt> <dd>
<p>Return <code>True</code> if <em>s</em> is a Python <a class="reference internal" href="../reference/lexical_analysis#keywords"><span class="std std-ref">keyword</span></a>.</p> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="keyword.kwlist">
<code>keyword.kwlist</code> </dt> <dd>
<p>Sequence containing all the <a class="reference internal" href="../reference/lexical_analysis#keywords"><span class="std std-ref">keywords</span></a> defined for the interpreter. If any keywords are defined to only be active when particular <a class="reference internal" href="__future__#module-__future__" title="__future__: Future statement definitions"><code>__future__</code></a> statements are in effect, these will be included as well.</p> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="keyword.issoftkeyword">
<code>keyword.issoftkeyword(s)</code> </dt> <dd>
<p>Return <code>True</code> if <em>s</em> is a Python <a class="reference internal" href="../reference/lexical_analysis#soft-keywords"><span class="std std-ref">soft keyword</span></a>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.9.</span></p> </div> </dd>
</dl> <dl class="py data"> <dt class="sig sig-object py" id="keyword.softkwlist">
<code>keyword.softkwlist</code> </dt> <dd>
<p>Sequence containing all the <a class="reference internal" href="../reference/lexical_analysis#soft-keywords"><span class="std std-ref">soft keywords</span></a> defined for the interpreter. If any soft keywords are defined to only be active when particular <a class="reference internal" href="__future__#module-__future__" title="__future__: Future statement definitions"><code>__future__</code></a> statements are in effect, these will be included as well.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.9.</span></p> </div> </dd>
</dl> <div class="_attribution">
<p class="_attribution-p">
© 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br>
<a href="https://docs.python.org/3.12/library/keyword.html" class="_attribution-link">https://docs.python.org/3.12/library/keyword.html</a>
</p>
</div>
|