Skip to content

Instantly share code, notes, and snippets.

@rajvijen
Created July 8, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajvijen/9cbbb5803590921b177f60325f5666d5 to your computer and use it in GitHub Desktop.
Save rajvijen/9cbbb5803590921b177f60325f5666d5 to your computer and use it in GitHub Desktop.
Language/Python/ Python_Practice.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {},
"cell_type": "markdown",
"source": "# Python Practice"
},
{
"metadata": {
"cell_style": "center",
"trusted": true
},
"cell_type": "code",
"source": "# This is an example snippet!\n# To create your own, add a new snippet block to the\n# snippets.json file in your jupyter nbextensions directory:\n# /nbextensions/snippets/snippets.json\nimport this\n",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"scrolled": false,
"trusted": true
},
"cell_type": "code",
"source": "from __future__ import print_function, division",
"execution_count": 5,
"outputs": []
},
{
"metadata": {},
"cell_type": "markdown",
"source": "* Tupples examples"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "v = ('a','b','c')\n(x,y,z) = v",
"execution_count": 8,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "x",
"execution_count": 9,
"outputs": [
{
"data": {
"text/plain": "'a'"
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "y",
"execution_count": 10,
"outputs": [
{
"data": {
"text/plain": "'b'"
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "x,y",
"execution_count": 11,
"outputs": [
{
"data": {
"text/plain": "('a', 'b')"
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "x = range(10)",
"execution_count": 13,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "x",
"execution_count": 14,
"outputs": [
{
"data": {
"text/plain": "range(0, 10)"
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "print(range.__doc__)",
"execution_count": 15,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "range(stop) -> range object\nrange(start, stop[, step]) -> range object\n\nReturn an object that produces a sequence of integers from start (inclusive)\nto stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.\nstart defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.\nThese are exactly the valid indices for a list of 4 elements.\nWhen step is given, it specifies the increment (or decrement).\n"
}
]
},
{
"metadata": {
"scrolled": true,
"trusted": true
},
"cell_type": "code",
"source": "# Bind the name getpass to the appropriate function\ntry:\n import termios, TERMIOS\nexcept ImportError:\n try:\n import msvcrt\n except ImportError:\n try:\n from EasyDialogs import AskPassword\n except ImportError:\n getpass = default_getpass\n else:\n getpass = AskPassword\n else:\n getpass = win_getpass\nelse:\n getpass = unix_getpass\n",
"execution_count": 18,
"outputs": [
{
"ename": "NameError",
"evalue": "name 'default_getpass' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-18-5cdcc5f31bf3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mtermios\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTERMIOS\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'TERMIOS'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-18-5cdcc5f31bf3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mmsvcrt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'msvcrt'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-18-5cdcc5f31bf3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mEasyDialogs\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mAskPassword\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'EasyDialogs'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-18-5cdcc5f31bf3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mEasyDialogs\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mAskPassword\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m \u001b[0mgetpass\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdefault_getpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 12\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0mgetpass\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mAskPassword\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'default_getpass' is not defined"
]
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "* termios is a UNIX−specific module that provides low−level control over the input terminal. If this module is\n not available (because it's not on your system, or your system doesn't support it), the import fails and Python\n raises an ImportError, which you catch.\n* OK, you didn't have termios, so let's try msvcrt, which is a Windows−specific module that provides an\n API to many useful functions in the Microsoft Visual C++ runtime services. If this import fails, Python will\n raise an ImportError, which you catch.\n* If the first two didn't work, you try to import a function from EasyDialogs, which is a Mac OS−specific\n module that provides functions to pop up dialog boxes of various types. Once again, if this import fails, Python\n will raise an ImportError, which you catch.\n* None of these platform−specific modules is available (which is possible, since Python has been ported to a lot\n of different platforms), so you need to fall back on a default password input function (which is defined\n elsewhere in the getpass module). Notice what you're doing here: assigning the function\n default_getpass to the variable getpass. If you read the official getpass documentation, it tells you\n that the getpass module defines a getpass function. It does this by binding getpass to the correct\n function for your platform. Then when you call the getpass function, you're really calling a\n platform−specific function that this code has set up for you. You don't need to know or care which platform\n your code is running on −− just call getpass, and it will always do the right thing.\n* A try...except block can have an else clause, like an if statement. If no exception is raised during the\n try block, the else clause is executed afterwards. In this case, that means that the from EasyDialogs\n import AskPassword import worked, so you should bind getpass to the AskPassword function.\n Each of the other try...except blocks has similar else clauses to bind getpass to the appropriate\n function when you find an import that works.\n"
},
{
"metadata": {
"cell_style": "center",
"scrolled": true,
"trusted": true
},
"cell_type": "code",
"source": "import os\nfor k, v in os.environ.items():\n print(k, v)\n \nprint([\"\\n\".join(k, v) for k, v in os.environ.items()]) ",
"execution_count": 24,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "CLUTTER_IM_MODULE xim\nCONDA_SHLVL 1\nLS_COLORS rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:\nCONDA_EXE /home/vijendra/anaconda3/bin/conda\nLESSCLOSE /usr/bin/lesspipe %s %s\nXDG_MENU_PREFIX gnome-\nLANG en_IN\nDISPLAY :0\nOLDPWD /home/vijendra/Desktop/AI\nGNOME_SHELL_SESSION_MODE ubuntu\nCOLORTERM truecolor\nGEM_HOME /home/vijendra/gems/bin:/home/vijendra/anaconda3/bin:/home/vijendra/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin\nUSERNAME vijendra\nCONDA_PREFIX /home/vijendra/anaconda3/envs/conda-forge_env\nXDG_VTNR 2\nSSH_AUTH_SOCK /run/user/1000/keyring/ssh\nMANDATORY_PATH /usr/share/gconf/ubuntu.mandatory.path\nXDG_SESSION_ID 51\nUSER vijendra\nDESKTOP_SESSION ubuntu\nQT4_IM_MODULE xim\nTEXTDOMAINDIR /usr/share/locale/\nGNOME_TERMINAL_SCREEN /org/gnome/Terminal/screen/9b8b58d0_2304_46bf_942f_b4abe8cce71d\nDEFAULTS_PATH /usr/share/gconf/ubuntu.default.path\nPWD /home/vijendra/Desktop/AI/Jupyter_Notebook\nHOME /home/vijendra\nCONDA_PYTHON_EXE /home/vijendra/anaconda3/bin/python\nTEXTDOMAIN im-config\nSSH_AGENT_PID 16323\nQT_ACCESSIBILITY 1\nXDG_SESSION_TYPE x11\nXDG_DATA_DIRS /usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop\nXDG_SESSION_DESKTOP ubuntu\nGJS_DEBUG_OUTPUT stderr\nCONDA_PROMPT_MODIFIER (conda-forge_env) \nGTK_MODULES gail:atk-bridge\nWINDOWPATH 2\nTERM xterm-color\nSHELL /bin/bash\nVTE_VERSION 5201\nQT_IM_MODULE ibus\nXMODIFIERS @im=ibus\nIM_CONFIG_PHASE 2\nXDG_CURRENT_DESKTOP ubuntu:GNOME\nGPG_AGENT_INFO /run/user/1000/gnupg/S.gpg-agent:0:1\nGNOME_TERMINAL_SERVICE :1.61\nXDG_SEAT seat0\nSHLVL 1\nGDMSESSION ubuntu\nGNOME_DESKTOP_SESSION_ID this-is-deprecated\nLOGNAME vijendra\nDBUS_SESSION_BUS_ADDRESS unix:path=/run/user/1000/bus\nXDG_RUNTIME_DIR /run/user/1000\nXAUTHORITY /run/user/1000/gdm/Xauthority\nXDG_CONFIG_DIRS /etc/xdg/xdg-ubuntu:/etc/xdg\nPATH /home/vijendra/anaconda3/envs/conda-forge_env/bin:/home/vijendra/anaconda3/envs/conda-forge_env/bin:/home/vijendra/anaconda3/bin:/home/vijendra/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin\nCONDA_DEFAULT_ENV conda-forge_env\nGJS_DEBUG_TOPICS JS ERROR;JS LOG\nGEM_MOME /home/vijendra/gems\nSESSION_MANAGER local/vijendra-hp:@/tmp/.ICE-unix/16229,unix/vijendra-hp:/tmp/.ICE-unix/16229\nLESSOPEN | /usr/bin/lesspipe %s\nGTK_IM_MODULE ibus\n_ /home/vijendra/anaconda3/envs/conda-forge_env/bin/jupyter\nJPY_PARENT_PID 30966\nCLICOLOR 1\nPAGER cat\nGIT_PAGER cat\nMPLBACKEND module://ipykernel.pylab.backend_inline\n"
},
{
"ename": "TypeError",
"evalue": "join() takes exactly one argument (2 given)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-24-7408a5cccc5d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"\\n\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0menviron\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m<ipython-input-24-7408a5cccc5d>\u001b[0m in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"\\n\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0menviron\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: join() takes exactly one argument (2 given)"
]
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "* os.environ is a dictionary of the environment variables defined on your system. In Windows, these are your\n user and system variables accessible from MS−DOS. In UNIX, they are the variables exported in your shell's\n startup scripts. In Mac OS, there is no concept of environment variables, so this dictionary is empty.\n* os.environ.items() returns a list of tuples: [(key1, value1), (key2, value2), ...]. The\n for loop iterates through this list. The first round, it assigns key1 to k and value1 to v, so k =\n USERPROFILE and v = C:\\Documents and Settings\\mpilgrim. In the second round, k gets the\n second key, OS, and v gets the corresponding value, Windows_NT.\n* With multi−variable assignment and list comprehensions, you can replace the entire for loop with a single\n statement. Whether you actually do this in real code is a matter of personal coding style. I like it because it\n makes it clear that what I'm doing is mapping a dictionary into a list, then joining the list into a single string.\n Other programmers prefer to write this out as a for loop. The output is the same in either case, although this\n version is slightly faster, because there is only one print statement instead of many."
},
{
"metadata": {
"scrolled": true,
"trusted": true
},
"cell_type": "code",
"source": "import sys\nprint(\"\\n\".join(sys.modules.keys()))",
"execution_count": 25,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "builtins\nsys\n_frozen_importlib\n_imp\n_warnings\n_thread\n_weakref\n_frozen_importlib_external\n_io\nmarshal\nposix\nzipimport\nencodings\ncodecs\n_codecs\nencodings.aliases\nencodings.utf_8\n_signal\n__main__\nencodings.latin_1\nio\nabc\n_weakrefset\n_bootlocale\n_locale\nsite\nos\nerrno\nstat\n_stat\nposixpath\ngenericpath\nos.path\n_collections_abc\n_sitebuiltins\nsysconfig\n_sysconfigdata_m_linux_x86_64-linux-gnu\ntypes\nfunctools\n_functools\ncollections\noperator\n_operator\nkeyword\nheapq\n_heapq\nitertools\nreprlib\n_collections\nweakref\ncollections.abc\nimportlib\nimportlib._bootstrap\nimportlib._bootstrap_external\nwarnings\nimportlib.util\nimportlib.abc\nimportlib.machinery\ncontextlib\nbackports\nmpl_toolkits\ngoogle\nsphinxcontrib\nzope\nencodings.cp437\nrunpy\npkgutil\nipykernel\nipykernel._version\nipykernel.connect\n__future__\njson\njson.decoder\nre\nenum\nsre_compile\n_sre\nsre_parse\nsre_constants\ncopyreg\njson.scanner\n_json\njson.encoder\nsubprocess\ntime\nsignal\n_posixsubprocess\nselect\nselectors\nmath\nthreading\ntraceback\nlinecache\ntokenize\ntoken\nIPython\nIPython.core\nIPython.core.getipython\nIPython.core.release\nIPython.core.application\natexit\ncopy\nglob\nfnmatch\nlogging\nstring\n_string\nshutil\nzlib\nbz2\n_compression\n_bz2\nlzma\n_lzma\npwd\ngrp\ntraitlets\ntraitlets.traitlets\ninspect\nast\n_ast\ndis\nopcode\n_opcode\nsix\nstruct\n_struct\ntraitlets.utils\ntraitlets.utils.getargspec\ntraitlets.utils.importstring\nipython_genutils\nipython_genutils._version\nipython_genutils.py3compat\nipython_genutils.encoding\nlocale\nplatform\ntraitlets.utils.sentinel\ntraitlets.utils.bunch\ntraitlets._version\ntraitlets.config\ntraitlets.config.application\ndecorator\ntraitlets.config.configurable\ntraitlets.config.loader\nargparse\ntextwrap\ngettext\nipython_genutils.path\nrandom\nhashlib\n_hashlib\n_blake2\n_sha3\nbisect\n_bisect\n_random\nipython_genutils.text\nipython_genutils.importstring\nIPython.core.crashhandler\npprint\nIPython.core.ultratb\npydoc\nurllib\nurllib.parse\nIPython.core.debugger\nbdb\nIPython.utils\nIPython.utils.PyColorize\nIPython.utils.coloransi\nIPython.utils.ipstruct\nIPython.utils.colorable\npygments\npygments.util\nIPython.utils.py3compat\nIPython.utils.encoding\nIPython.core.excolors\nIPython.testing\nIPython.testing.skipdoctest\npdb\ncmd\ncode\ncodeop\nIPython.core.display_trap\nIPython.utils.openpy\nIPython.utils.path\nIPython.utils.process\nIPython.utils._process_posix\npexpect\npexpect.exceptions\npexpect.utils\npexpect.expect\npexpect.pty_spawn\npty\ntty\ntermios\nptyprocess\nptyprocess.ptyprocess\nfcntl\nresource\nptyprocess.util\npexpect.spawnbase\npexpect.run\nIPython.utils._process_common\nshlex\nIPython.utils.decorators\nIPython.utils.data\nIPython.utils.terminal\nIPython.utils.sysinfo\nIPython.utils._sysinfo\nIPython.core.profiledir\nIPython.paths\ntempfile\nIPython.utils.importstring\nIPython.terminal\nIPython.terminal.embed\nIPython.core.compilerop\nIPython.core.magic_arguments\nIPython.core.error\nIPython.utils.text\npathlib\nntpath\nIPython.core.magic\ngetopt\nIPython.core.oinspect\nIPython.core.page\nIPython.core.display\nbinascii\nmimetypes\nIPython.lib\nIPython.lib.security\ngetpass\nIPython.lib.pretty\ndatetime\n_datetime\nIPython.utils.signatures\nIPython.utils.dir2\nIPython.utils.wildcard\npygments.lexers\npygments.lexers._mapping\npygments.modeline\npygments.plugin\npygments.lexers.python\npygments.lexer\npygments.filter\npygments.filters\npygments.token\npygments.regexopt\npygments.unistring\npygments.formatters\npygments.formatters._mapping\npygments.formatters.html\npygments.formatter\npygments.styles\nIPython.core.inputsplitter\nIPython.core.inputtransformer\nIPython.core.splitinput\nIPython.utils.tokenize2\nIPython.core.interactiveshell\npickleshare\npickle\n_compat_pickle\n_pickle\nIPython.core.prefilter\nIPython.core.autocall\nIPython.core.macro\nIPython.core.alias\nIPython.core.builtin_trap\nIPython.core.events\nbackcall\nbackcall.backcall\nIPython.core.displayhook\nIPython.core.displaypub\nIPython.core.extensions\nIPython.core.formatters\nIPython.utils.sentinel\nIPython.core.history\nsqlite3\nsqlite3.dbapi2\n_sqlite3\nIPython.core.logger\nIPython.core.payload\nIPython.core.usage\nIPython.display\nIPython.lib.display\nhtml\nhtml.entities\nIPython.utils.io\nIPython.utils.capture\nIPython.utils.strdispatch\nIPython.core.hooks\nIPython.utils.syspathcontext\nIPython.utils.tempdir\ntyping\ntyping.io\ntyping.re\nIPython.utils.contexts\nIPython.terminal.interactiveshell\nprompt_toolkit\nprompt_toolkit.interface\nprompt_toolkit.application\nprompt_toolkit.buffer\nprompt_toolkit.auto_suggest\nprompt_toolkit.filters\nprompt_toolkit.filters.base\nprompt_toolkit.utils\nwcwidth\nwcwidth.wcwidth\nwcwidth.table_wide\nwcwidth.table_zero\nsix.moves\nprompt_toolkit.filters.cli\nprompt_toolkit.enums\nprompt_toolkit.key_binding\nprompt_toolkit.key_binding.vi_state\nprompt_toolkit.cache\nprompt_toolkit.filters.types\nprompt_toolkit.filters.utils\nprompt_toolkit.clipboard\nprompt_toolkit.clipboard.base\nprompt_toolkit.selection\nprompt_toolkit.clipboard.in_memory\nprompt_toolkit.completion\nprompt_toolkit.document\nprompt_toolkit.history\nprompt_toolkit.search_state\nprompt_toolkit.validation\nprompt_toolkit.buffer_mapping\nprompt_toolkit.key_binding.bindings\nprompt_toolkit.key_binding.bindings.basic\nprompt_toolkit.keys\nprompt_toolkit.layout\nprompt_toolkit.layout.containers\nprompt_toolkit.layout.controls\nprompt_toolkit.mouse_events\nprompt_toolkit.token\nprompt_toolkit.layout.lexers\nprompt_toolkit.layout.utils\nprompt_toolkit.layout.processors\nprompt_toolkit.reactive\nprompt_toolkit.layout.screen\nprompt_toolkit.layout.dimension\nprompt_toolkit.layout.margins\nprompt_toolkit.renderer\nprompt_toolkit.layout.mouse_handlers\nprompt_toolkit.output\nprompt_toolkit.styles\nprompt_toolkit.styles.base\nprompt_toolkit.styles.defaults\nprompt_toolkit.styles.from_dict\nprompt_toolkit.styles.utils\nprompt_toolkit.styles.from_pygments\npygments.style\npygments.styles.default\nprompt_toolkit.key_binding.bindings.named_commands\nprompt_toolkit.key_binding.bindings.completion\nprompt_toolkit.key_binding.registry\nprompt_toolkit.key_binding.input_processor\nprompt_toolkit.key_binding.bindings.emacs\nprompt_toolkit.key_binding.bindings.scroll\nprompt_toolkit.key_binding.bindings.vi\nprompt_toolkit.key_binding.digraphs\nprompt_toolkit.key_binding.defaults\nprompt_toolkit.eventloop\nprompt_toolkit.eventloop.base\nprompt_toolkit.eventloop.callbacks\nprompt_toolkit.input\nprompt_toolkit.terminal\nprompt_toolkit.terminal.vt100_input\nprompt_toolkit.shortcuts\nprompt_toolkit.layout.menus\nprompt_toolkit.layout.prompt\nprompt_toolkit.layout.toolbars\nprompt_toolkit.terminal.vt100_output\narray\nprompt_toolkit.key_binding.manager\nIPython.terminal.debugger\nIPython.core.completer\nunicodedata\nIPython.core.latex_symbols\nIPython.utils.generics\nsimplegeneric\njedi\njedi.api\nparso\nparso.parser\nparso.tree\nparso._compatibility\nparso.pgen2\nparso.pgen2.parse\nparso.python\nparso.python.tokenize\nparso.python.token\nparso.utils\nparso.grammar\nparso.pgen2.pgen\nparso.pgen2.grammar\nparso.python.diff\ndifflib\nparso.python.parser\nparso.python.tree\nparso.python.prefix\nparso.cache\ngc\nparso.python.errors\nparso.normalizer\nparso.python.pep8\njedi._compatibility\nqueue\njedi.parser_utils\njedi.debug\ncolorama\ncolorama.initialise\ncolorama.ansitowin32\ncolorama.ansi\ncolorama.winterm\ncolorama.win32\nctypes\n_ctypes\nctypes._endian\njedi.settings\njedi.cache\njedi.api.classes\njedi.evaluate\njedi.evaluate.utils\njedi.evaluate.imports\njedi.evaluate.sys_path\njedi.evaluate.cache\njedi.evaluate.base_context\njedi.common\njedi.common.context\njedi.evaluate.helpers\njedi.evaluate.compiled\njedi.evaluate.compiled.context\njedi.evaluate.filters\njedi.evaluate.flow_analysis\njedi.evaluate.recursion\njedi.evaluate.lazy_context\njedi.evaluate.compiled.access\njedi.evaluate.compiled.getattr_static\njedi.evaluate.compiled.fake\njedi.common.utils\njedi.evaluate.analysis\njedi.evaluate.context\njedi.evaluate.context.module\njedi.evaluate.context.klass\njedi.evaluate.context.function\njedi.evaluate.docstrings\njedi.evaluate.pep0484\njedi.evaluate.arguments\njedi.evaluate.context.iterable\njedi.evaluate.param\njedi.evaluate.context.asynchronous\njedi.evaluate.parser_cache\njedi.evaluate.context.instance\njedi.evaluate.syntax_tree\njedi.evaluate.finder\njedi.api.keywords\npydoc_data\npydoc_data.topics\njedi.api.interpreter\njedi.evaluate.compiled.mixed\njedi.api.helpers\njedi.api.completion\njedi.api.environment\nfilecmp\ndistutils\ndistutils.spawn\ndistutils.errors\ndistutils.debug\ndistutils.log\njedi.evaluate.compiled.subprocess\nsocket\n_socket\njedi.evaluate.compiled.subprocess.functions\njedi.api.exceptions\njedi.api.project\njedi.evaluate.usages\nIPython.terminal.ptutils\nIPython.terminal.shortcuts\nIPython.terminal.magics\nIPython.lib.clipboard\nIPython.terminal.pt_inputhooks\nIPython.terminal.prompts\nIPython.terminal.ipapp\nIPython.core.magics\nIPython.core.magics.auto\nIPython.core.magics.basic\nIPython.core.magics.code\nIPython.core.magics.config\nIPython.core.magics.display\nIPython.core.magics.execution\ntimeit\ncProfile\n_lsprof\nprofile\noptparse\npstats\nIPython.utils.module_paths\nimp\nIPython.utils.timing\nIPython.core.magics.extension\nIPython.core.magics.history\nIPython.core.magics.logging\nIPython.core.magics.namespace\nIPython.core.magics.osm\nIPython.core.magics.pylab\nIPython.core.pylabtools\nIPython.core.magics.script\nIPython.lib.backgroundjobs\nIPython.core.shellapp\nIPython.extensions\nIPython.extensions.storemagic\nIPython.utils.frame\njupyter_client\njupyter_client._version\njupyter_client.connect\nzmq\nzmq.backend\nzmq.backend.select\nzmq.backend.cython\ncython_runtime\nzmq.backend.cython.constants\n_cython_0_27_3\nzmq.backend.cython.error\nzmq.utils\nzmq.utils.strtypes\nzmq.backend.cython.message\nzmq.error\nzmq.backend.cython.context\nzmq.backend.cython.socket\nzmq.backend.cython.utils\nzmq.backend.cython._poll\nzmq.backend.cython._version\nzmq.backend.cython._device\nzmq.sugar\nzmq.sugar.constants\nzmq.utils.constant_names\nzmq.sugar.context\nzmq.sugar.attrsettr\nzmq.sugar.socket\nzmq.sugar.poll\nzmq.sugar.frame\nzmq.sugar.tracker\nzmq.sugar.version\nzmq.sugar.stopwatch\njupyter_client.localinterfaces\njupyter_core\njupyter_core.version\njupyter_core.paths\njupyter_client.launcher\ntraitlets.log\njupyter_client.client\njupyter_client.channels\njupyter_client.channelsabc\njupyter_client.clientabc\njupyter_client.manager\njupyter_client.kernelspec\njupyter_client.managerabc\njupyter_client.blocking\njupyter_client.blocking.client\njupyter_client.blocking.channels\njupyter_client.multikernelmanager\nuuid\nctypes.util\nipykernel.kernelapp\ntornado\ntornado.ioloop\nnumbers\ntornado.concurrent\ntornado.log\nlogging.handlers\ntornado.escape\ntornado.util\ntornado.speedups\ncurses\n_curses\ntornado.stack_context\nconcurrent\nconcurrent.futures\nconcurrent.futures._base\nconcurrent.futures.process\nmultiprocessing\nmultiprocessing.context\nmultiprocessing.process\nmultiprocessing.reduction\n__mp_main__\nmultiprocessing.connection\n_multiprocessing\nmultiprocessing.util\nconcurrent.futures.thread\nasyncio\nasyncio.base_events\nasyncio.compat\nasyncio.coroutines\nasyncio.constants\nasyncio.events\nasyncio.base_futures\nasyncio.log\nasyncio.futures\nasyncio.base_tasks\n_asyncio\nasyncio.tasks\nasyncio.locks\nasyncio.protocols\nasyncio.queues\nasyncio.streams\nasyncio.subprocess\nasyncio.transports\nasyncio.unix_events\nasyncio.base_subprocess\nasyncio.selector_events\nssl\nipaddress\n_ssl\nbase64\nasyncio.sslproto\ntornado.platform\ntornado.platform.auto\ntornado.platform.posix\ntornado.platform.common\ntornado.platform.interface\nzmq.eventloop\nzmq.eventloop.ioloop\ntornado.platform.asyncio\ntornado.gen\nzmq.eventloop.zmqstream\nzmq.utils.jsonapi\nipykernel.iostream\njupyter_client.session\nhmac\njupyter_client.jsonutil\ndateutil\ndateutil._version\ndateutil.parser\ndateutil.parser._parser\ncalendar\ndecimal\n_decimal\ndateutil.relativedelta\ndateutil._common\ndateutil.tz\ndateutil.tz.tz\ndateutil.tz._common\ndateutil.tz._factories\ndateutil.parser.isoparser\n_strptime\njupyter_client.adapter\nipykernel.heartbeat\nipykernel.ipkernel\nIPython.utils.tokenutil\nipykernel.comm\nipykernel.comm.manager\nipykernel.comm.comm\nipykernel.kernelbase\nipykernel.jsonutil\nipykernel.zmqshell\nIPython.core.payloadpage\nipykernel.displayhook\nipykernel.parentpoller\nfaulthandler\nipykernel.datapub\nipykernel.serialize\nipykernel.pickleutil\nipyparallel\nipyparallel._version\nipyparallel.serialize\nipyparallel.serialize.canning\nipyparallel.serialize.codeutil\nipyparallel.serialize.serialize\nipyparallel.client\nipyparallel.client.asyncresult\nipyparallel.error\nipyparallel.util\nzmq.log\nzmq.log.handlers\ndistutils.version\nipyparallel.client.futures\nipyparallel.client.client\nipyparallel.client.view\nipyparallel.controller\nipyparallel.controller.dependency\nipyparallel.client.map\nipyparallel.client.remotefunction\nIPython.core.completerlib\nstoremagic\nipywidgets\nipywidgets._version\nipywidgets.widgets\nipywidgets.widgets.widget\nipywidgets.widgets.domwidget\nipywidgets.widgets.trait_types\nipywidgets.widgets.widget_layout\nipywidgets.widgets.widget_style\nipywidgets.widgets.valuewidget\nipywidgets.widgets.widget_core\nipywidgets.widgets.widget_bool\nipywidgets.widgets.widget_description\nipywidgets.widgets.widget_button\nipywidgets.widgets.widget_box\nipywidgets.widgets.docutils\nipywidgets.widgets.widget_float\nipywidgets.widgets.widget_int\nipywidgets.widgets.widget_image\nipywidgets.widgets.widget_color\nipywidgets.widgets.widget_date\nipywidgets.widgets.widget_output\nipywidgets.widgets.widget_selection\nipywidgets.widgets.widget_selectioncontainer\nipywidgets.widgets.widget_string\nipywidgets.widgets.widget_controller\nipywidgets.widgets.interaction\nipywidgets.widgets.widget_link\n"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "**Modules, like everything else in Python, are objects. Once imported, you can always get a reference to a module\nthrough the global dictionary sys.modules.**"
},
{
"metadata": {},
"cell_type": "markdown",
"source": "* The sys module contains system−level information, such as the version of Python you're\n running (sys.version or sys.version_info), and system−level options such as the\n maximum allowed recursion depth (sys.getrecursionlimit() and\n sys.setrecursionlimit()).\n* sys.modules is a dictionary containing all the modules that have ever been imported since\n Python was started; the key is the module name, the value is the module object. Note that this is\n more than just the modules your program has imported. Python preloads some modules on\n startup, and if you're using a Python IDE, sys.modules contains all the modules imported by\n all the programs you've run within the IDE"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"gist": {
"id": "",
"data": {
"description": "Language/Python/ Python_Practice.ipynb",
"public": true
}
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.6.5",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"base_numbering": 1,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment