{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 2021-05-21" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Modules and Packages" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import sys" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'3.9.4 (default, Apr 6 2021, 00:00:00) \\n[GCC 11.0.1 20210324 (Red Hat 11.0.1-0)]'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sys.version" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "try:\n", " sys.exit()\n", "except SystemExit as e:\n", " print(e)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "module" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(sys)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "orig_sys = sys\n", "sys = 666" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "'int' object has no attribute 'exit'\n" ] } ], "source": [ "try:\n", " sys.exit()\n", "except Exception as e:\n", " print(e)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'3.9.4 (default, Apr 6 2021, 00:00:00) \\n[GCC 11.0.1 20210324 (Red Hat 11.0.1-0)]'" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sys = orig_sys\n", "sys.version" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'3.9.4 (default, Apr 6 2021, 00:00:00) \\n[GCC 11.0.1 20210324 (Red Hat 11.0.1-0)]'" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sys import version\n", "version" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'3.9.4 (default, Apr 6 2021, 00:00:00) \\n[GCC 11.0.1 20210324 (Red Hat 11.0.1-0)]'" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import sys\n", "blah = sys\n", "del sys\n", "blah.version" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'3.9.4 (default, Apr 6 2021, 00:00:00) \\n[GCC 11.0.1 20210324 (Red Hat 11.0.1-0)]'" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import sys as blah\n", "blah.version" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "# from sys import *" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['__breakpointhook__',\n", " '__displayhook__',\n", " '__doc__',\n", " '__excepthook__',\n", " '__interactivehook__',\n", " '__loader__',\n", " '__name__',\n", " '__package__',\n", " '__spec__',\n", " '__stderr__',\n", " '__stdin__',\n", " '__stdout__',\n", " '__unraisablehook__',\n", " '_base_executable',\n", " '_clear_type_cache',\n", " '_current_frames',\n", " '_debugmallocstats',\n", " '_framework',\n", " '_getframe',\n", " '_git',\n", " '_home',\n", " '_xoptions',\n", " 'abiflags',\n", " 'addaudithook',\n", " 'api_version',\n", " 'argv',\n", " 'audit',\n", " 'base_exec_prefix',\n", " 'base_prefix',\n", " 'breakpointhook',\n", " 'builtin_module_names',\n", " 'byteorder',\n", " 'call_tracing',\n", " 'copyright',\n", " 'displayhook',\n", " 'dont_write_bytecode',\n", " 'exc_info',\n", " 'excepthook',\n", " 'exec_prefix',\n", " 'executable',\n", " 'exit',\n", " 'flags',\n", " 'float_info',\n", " 'float_repr_style',\n", " 'get_asyncgen_hooks',\n", " 'get_coroutine_origin_tracking_depth',\n", " 'getallocatedblocks',\n", " 'getdefaultencoding',\n", " 'getdlopenflags',\n", " 'getfilesystemencodeerrors',\n", " 'getfilesystemencoding',\n", " 'getprofile',\n", " 'getrecursionlimit',\n", " 'getrefcount',\n", " 'getsizeof',\n", " 'getswitchinterval',\n", " 'gettrace',\n", " 'hash_info',\n", " 'hexversion',\n", " 'implementation',\n", " 'int_info',\n", " 'intern',\n", " 'is_finalizing',\n", " 'last_traceback',\n", " 'last_type',\n", " 'last_value',\n", " 'maxsize',\n", " 'maxunicode',\n", " 'meta_path',\n", " 'modules',\n", " 'path',\n", " 'path_hooks',\n", " 'path_importer_cache',\n", " 'platform',\n", " 'platlibdir',\n", " 'prefix',\n", " 'ps1',\n", " 'ps2',\n", " 'ps3',\n", " 'pycache_prefix',\n", " 'set_asyncgen_hooks',\n", " 'set_coroutine_origin_tracking_depth',\n", " 'setdlopenflags',\n", " 'setprofile',\n", " 'setrecursionlimit',\n", " 'setswitchinterval',\n", " 'settrace',\n", " 'stderr',\n", " 'stdin',\n", " 'stdout',\n", " 'thread_info',\n", " 'unraisablehook',\n", " 'version',\n", " 'version_info',\n", " 'warnoptions']" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import sys\n", "dir(sys)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.9.4" } }, "nbformat": 4, "nbformat_minor": 4 }