Built-in Keywords: Difference between revisions
From Master of Neuroscience Wiki
Created page with " == The goal == You need to know the keywords for Python because you should not use them as variable, class, or function names. Questions to [mailto:davrot@uni-bremen.de David Rotermund] == [https://docs.python.org/3/library/keyword.html Keywords] == <syntaxhighlight lang="python">import keyword print(keyword.kwlist) print() print(keyword.softkwlist) # -> ['_', 'case', 'match']</syntaxhighlight>Output:<syntaxhighlight lang="python">['False', 'None', 'True', 'and', 'as..." |
No edit summary |
||
| Line 1: | Line 1: | ||
You need to know the keywords for Python because you should not use them as variable, class, or function names. | You need to know the keywords for Python because you should not use them as variable, class, or function names. | ||
Latest revision as of 16:17, 17 October 2025
You need to know the keywords for Python because you should not use them as variable, class, or function names.
Questions to David Rotermund
Keywords
import keyword
print(keyword.kwlist)
print()
print(keyword.softkwlist) # -> ['_', 'case', 'match']
Output:
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
| False |
| None |
| True |
| and |
| as |
| assert |
| async |
| await |
| break |
| class |
| continue |
| def |
| del |
| elif |
| else |
| except |
| finally |
| for |
| from |
| global |
| if |
| import |
| in |
| is |
| lambda |
| nonlocal |
| not |
| or |
| pass |
| raise |
| return |
| try |
| while |
| with |
| yield |
| _ |
| case |
| match |