Skip to content

Commit 11b72d2

Browse files
committed
🎨 Better structure for variables and expressions
1 parent 3d87959 commit 11b72d2

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

docs/variables-expressions.rst

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,38 +52,41 @@ variables can only be stored in the declared type.
5252
Variable names are case-sensitive and can contain any alphanumeric character as
5353
well as underscores, but must begin with a letter or underscore.
5454

55-
.. note::
56-
If you receive a ``SyntaxError``, check whether the variable name is a
57-
keyword. Keywords are reserved for use in Python language constructs, so you
58-
cannot turn them into variables. After calling :ref:`help` you can enter
59-
``keywords`` to get the keywords:
55+
Keywords
56+
--------
6057

61-
.. code-block:: pycon
58+
If you receive a ``SyntaxError``, check whether the variable name is a keyword.
59+
Keywords are reserved for use in Python language constructs, so you cannot turn
60+
them into variables. After calling :ref:`help` you can enter ``keywords`` to get
61+
the keywords:
6262

63-
>>> help()
64-
help> keywords
65-
Here is a list of the Python keywords. Enter any keyword to get more help.
66-
False class from or
67-
None continue global pass
68-
True def if raise
69-
and del import return
70-
as elif in try
71-
assert else is while
72-
async except lambda with
73-
await finally nonlocal yield
74-
break for not
63+
.. code-block:: pycon
7564
76-
.. note::
77-
You can use a variable name to overwrite built-in functions, types and other
78-
objects so that they can then only be accessed via the :doc:`builtins
79-
<python3:library/builtins>` module. These variable names should therefore
80-
never be used. You can obtain a list of the :mod:`__builtins__` objects
81-
with :
65+
>>> help()
66+
help> keywords
67+
Here is a list of the Python keywords. Enter any keyword to get more help.
68+
False class from or
69+
None continue global pass
70+
True def if raise
71+
and del import return
72+
as elif in try
73+
assert else is while
74+
async except lambda with
75+
await finally nonlocal yield
76+
break for not
77+
78+
Built-in functions
79+
------------------
80+
81+
You can use a variable name to overwrite built-in functions, types and other
82+
objects so that they can then only be accessed via the :doc:`builtins
83+
<python3:library/builtins>` module. These variable names should therefore never
84+
be used. You can obtain a list of the :mod:`__builtins__` objects with:
8285

83-
.. code-block:: pycon
86+
.. code-block:: pycon
8487
85-
>>> dir(__builtins__)
86-
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BaseExceptionGroup', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EncodingWarning', 'EnvironmentError', 'Exception', 'ExceptionGroup', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '__build_class__', '__debug__', '__doc__', '__import__', '__loader__', '__name__', '__package__', '__spec__', 'abs', 'aiter', 'all', 'anext', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
88+
>>> dir(__builtins__)
89+
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BaseExceptionGroup', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EncodingWarning', 'EnvironmentError', 'Exception', 'ExceptionGroup', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '__build_class__', '__debug__', '__doc__', '__import__', '__loader__', '__name__', '__package__', '__spec__', 'abs', 'aiter', 'all', 'anext', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
8790
8891
Expressions
8992
-----------

0 commit comments

Comments
 (0)