-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72485b7
commit e9cacec
Showing
2 changed files
with
574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,306 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"References http://python-history.blogspot.com/2013/11/story-of-none-true-false.html" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Builtins" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"['ArithmeticError',\n", | ||
" 'AssertionError',\n", | ||
" 'AttributeError',\n", | ||
" 'BaseException',\n", | ||
" 'BaseExceptionGroup',\n", | ||
" 'BlockingIOError',\n", | ||
" 'BrokenPipeError',\n", | ||
" 'BufferError',\n", | ||
" 'BytesWarning',\n", | ||
" 'ChildProcessError',\n", | ||
" 'ConnectionAbortedError',\n", | ||
" 'ConnectionError',\n", | ||
" 'ConnectionRefusedError',\n", | ||
" 'ConnectionResetError',\n", | ||
" 'DeprecationWarning',\n", | ||
" 'EOFError',\n", | ||
" 'Ellipsis',\n", | ||
" 'EncodingWarning',\n", | ||
" 'EnvironmentError',\n", | ||
" 'Exception',\n", | ||
" 'ExceptionGroup',\n", | ||
" 'False',\n", | ||
" 'FileExistsError',\n", | ||
" 'FileNotFoundError',\n", | ||
" 'FloatingPointError',\n", | ||
" 'FutureWarning',\n", | ||
" 'GeneratorExit',\n", | ||
" 'IOError',\n", | ||
" 'ImportError',\n", | ||
" 'ImportWarning',\n", | ||
" 'IndentationError',\n", | ||
" 'IndexError',\n", | ||
" 'InterruptedError',\n", | ||
" 'IsADirectoryError',\n", | ||
" 'KeyError',\n", | ||
" 'KeyboardInterrupt',\n", | ||
" 'LookupError',\n", | ||
" 'MemoryError',\n", | ||
" 'ModuleNotFoundError',\n", | ||
" 'NameError',\n", | ||
" 'None',\n", | ||
" 'NotADirectoryError',\n", | ||
" 'NotImplemented',\n", | ||
" 'NotImplementedError',\n", | ||
" 'OSError',\n", | ||
" 'OverflowError',\n", | ||
" 'PendingDeprecationWarning',\n", | ||
" 'PermissionError',\n", | ||
" 'ProcessLookupError',\n", | ||
" 'RecursionError',\n", | ||
" 'ReferenceError',\n", | ||
" 'ResourceWarning',\n", | ||
" 'RuntimeError',\n", | ||
" 'RuntimeWarning',\n", | ||
" 'StopAsyncIteration',\n", | ||
" 'StopIteration',\n", | ||
" 'SyntaxError',\n", | ||
" 'SyntaxWarning',\n", | ||
" 'SystemError',\n", | ||
" 'SystemExit',\n", | ||
" 'TabError',\n", | ||
" 'TimeoutError',\n", | ||
" 'True',\n", | ||
" 'TypeError',\n", | ||
" 'UnboundLocalError',\n", | ||
" 'UnicodeDecodeError',\n", | ||
" 'UnicodeEncodeError',\n", | ||
" 'UnicodeError',\n", | ||
" 'UnicodeTranslateError',\n", | ||
" 'UnicodeWarning',\n", | ||
" 'UserWarning',\n", | ||
" 'ValueError',\n", | ||
" 'Warning',\n", | ||
" 'ZeroDivisionError',\n", | ||
" '__IPYTHON__',\n", | ||
" '__build_class__',\n", | ||
" '__debug__',\n", | ||
" '__doc__',\n", | ||
" '__import__',\n", | ||
" '__loader__',\n", | ||
" '__name__',\n", | ||
" '__package__',\n", | ||
" '__spec__',\n", | ||
" 'abs',\n", | ||
" 'aiter',\n", | ||
" 'all',\n", | ||
" 'anext',\n", | ||
" 'any',\n", | ||
" 'ascii',\n", | ||
" 'bin',\n", | ||
" 'bool',\n", | ||
" 'breakpoint',\n", | ||
" 'bytearray',\n", | ||
" 'bytes',\n", | ||
" 'callable',\n", | ||
" 'chr',\n", | ||
" 'classmethod',\n", | ||
" 'compile',\n", | ||
" 'complex',\n", | ||
" 'copyright',\n", | ||
" 'credits',\n", | ||
" 'delattr',\n", | ||
" 'dict',\n", | ||
" 'dir',\n", | ||
" 'display',\n", | ||
" 'divmod',\n", | ||
" 'enumerate',\n", | ||
" 'eval',\n", | ||
" 'exec',\n", | ||
" 'execfile',\n", | ||
" 'filter',\n", | ||
" 'float',\n", | ||
" 'format',\n", | ||
" 'frozenset',\n", | ||
" 'get_ipython',\n", | ||
" 'getattr',\n", | ||
" 'globals',\n", | ||
" 'hasattr',\n", | ||
" 'hash',\n", | ||
" 'help',\n", | ||
" 'hex',\n", | ||
" 'id',\n", | ||
" 'input',\n", | ||
" 'int',\n", | ||
" 'isinstance',\n", | ||
" 'issubclass',\n", | ||
" 'iter',\n", | ||
" 'len',\n", | ||
" 'license',\n", | ||
" 'list',\n", | ||
" 'locals',\n", | ||
" 'map',\n", | ||
" 'max',\n", | ||
" 'memoryview',\n", | ||
" 'min',\n", | ||
" 'next',\n", | ||
" 'object',\n", | ||
" 'oct',\n", | ||
" 'open',\n", | ||
" 'ord',\n", | ||
" 'pow',\n", | ||
" 'print',\n", | ||
" 'property',\n", | ||
" 'range',\n", | ||
" 'repr',\n", | ||
" 'reversed',\n", | ||
" 'round',\n", | ||
" 'runfile',\n", | ||
" 'set',\n", | ||
" 'setattr',\n", | ||
" 'slice',\n", | ||
" 'sorted',\n", | ||
" 'staticmethod',\n", | ||
" 'str',\n", | ||
" 'sum',\n", | ||
" 'super',\n", | ||
" 'tuple',\n", | ||
" 'type',\n", | ||
" 'vars',\n", | ||
" 'zip']" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"dir(__builtins__)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"Copyright (c) 2001-2023 Python Software Foundation.\n", | ||
"All Rights Reserved.\n", | ||
"\n", | ||
"Copyright (c) 2000 BeOpen.com.\n", | ||
"All Rights Reserved.\n", | ||
"\n", | ||
"Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n", | ||
"All Rights Reserved.\n", | ||
"\n", | ||
"Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n", | ||
"All Rights Reserved." | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"copyright" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Python builtins can be overwritten" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"copyright = 3\n", | ||
"int = 4\n", | ||
"abs = 3" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Literals cannot ve overwritten because the parser detects an invalid syntax." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "SyntaxError", | ||
"evalue": "cannot assign to None (475422665.py, line 1)", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;36m Cell \u001b[0;32mIn[5], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m None = 2\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m cannot assign to None\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Doesn't work\n", | ||
"None = 2\n", | ||
"2 = 3\n", | ||
"\"a\" = 3" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "quantum", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.3" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.