{"id":197,"date":"2019-02-08T05:31:39","date_gmt":"2019-02-08T05:31:39","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/python\/?p=197"},"modified":"2019-03-02T03:56:06","modified_gmt":"2019-03-02T03:56:06","slug":"17-python-modules","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/","title":{"rendered":"Python &#8211; Modules"},"content":{"rendered":"<p>A module in Python is a container for codes. So you can defined functions, classes and variables inside a module. Let&#8217;s say you have a function you have written. This function contains several lines of code and you want to use them in different files. In this case, you can place this function in a module.<\/p>\n<p>We would cover the following:<\/p>\n<ol>\n<li><a href=\"#t1\">How to Create a Module<\/a><\/li>\n<li><a href=\"#t2\">HowThe import Statement<\/a><\/li>\n<li><a href=\"#t3\">HowThe from&#8230;import Statement<\/a><\/li>\n<li><a href=\"#t4\">HowLocating Modules<\/a><\/li>\n<li><a href=\"#t5\">HowThe dir () Function<\/a><\/li>\n<li><a href=\"#t6\">HowThe globals() and locals() Functions<\/a><\/li>\n<li><a href=\"#t7\">HowThe reload() Function<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. How to create a module<\/strong><\/h4>\n<p>To create a module, you first create a Python file and save it with the name of the module. So if you want to create a module called mycodes, then you would first create a file called mycodes.py. Inside this file you can then write the functions or other codes you want to reuse.<\/p>\n<p>Now, there are modules that are built-in that you can just use. For example, the math module that contains useful functions for performing arithmetic. The random module for working with random numbers and sequences, and lots more.<\/p>\n<p>You can scroll down to the video and watch how this is done.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. The import Statement<\/strong><\/h4>\n<p>To use the codes in the module, you simply use the import statement. So if you have created a module called mycodes, the to use it in any file, you must add import mycodes in the new file.<\/p>\n<p>You can also import more than one module. For example,<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">mycodes<\/span>\r\n<\/pre>\n<p>When an import statement is encountered, then the interpreter searches the current path for the module. If it finds it, then it imports it into the program.<\/p>\n<p>Now, after importing a module, you are free to use the functions available in the module. You simply use them by using this syntax below.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">modulename<span style=\"color: #333333;\">.<\/span>functionname\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong id=\"t3\">3. The from&#8230;import Statement<\/strong><\/p>\n<p>Let&#8217;s say a module contains 100 functions, and you want to use only one of them. You\u00a0 don&#8217;t have to import the whole module. The from&#8230;import statement allows you to import just a block of code or function from a module.<\/p>\n<p>So if you have a module called modulename and the name of the function you want to use is functionname, you can used the syntax below<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">modulename<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> functioname\r\n<\/pre>\n<p>So this ensures that you import only the particular function<\/p>\n<p>&nbsp;<\/p>\n<p>You can also use the <em><strong>from module import *<\/strong><\/em> statement. In this case, you are importing all the functions from a module into the current namespace.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Locating Modules<\/strong><\/h4>\n<p>When you use an import statement, the Python interpreter checks for the module in following locations in order.<\/p>\n<ul>\n<li>The current directory<\/li>\n<li>If the module is not there, then Python searches each directory in the <strong><em>PYTHONPATH<\/em> <\/strong>shell variable<\/li>\n<li>If not found, Python then searches the default path.<\/li>\n<\/ul>\n<p>The variable that contains the module search path is the <strong><em>sys.path<\/em><\/strong> variable. The sys.path variable contains the PYTHONPATH, the current directory as well as the installation-dependent default.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>The PYTHONPATH variable<\/strong><\/p>\n<p>The PYTHONPATH is an environment variable used by Python. it contains list of directories that Python searches for modules. You can also change the location of this directory using <em><strong>set PYTHONPATH<\/strong><\/em> command.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t5\">5. The dir( ) Function<\/strong><\/h4>\n<p>This is an important built-in function in Python. The dir() function returns an sorted list of strings containing names that are defined in a module.<\/p>\n<p>This list would contain all functions, modules, variables defined inside the specified module. For example, the code below lists the content of the math module.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\"># import the math built-in module<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">math<\/span>\r\n\r\nlistofitems <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">dir<\/span>(math)\r\n<span style=\"color: #007020;\">print<\/span>(listofitems)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If you execute the code then you will get the list of items below.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">[<span style=\"background-color: #fff0f0;\">'__doc__'<\/span>, <span style=\"background-color: #fff0f0;\">'__loader__'<\/span>, <span style=\"background-color: #fff0f0;\">'__name__'<\/span>, <span style=\"background-color: #fff0f0;\">'__package__'<\/span>, <span style=\"background-color: #fff0f0;\">'__spec__'<\/span>, \r\n<span style=\"background-color: #fff0f0;\">'acos'<\/span>, <span style=\"background-color: #fff0f0;\">'acosh'<\/span>, <span style=\"background-color: #fff0f0;\">'asin'<\/span>, <span style=\"background-color: #fff0f0;\">'asinh'<\/span>, <span style=\"background-color: #fff0f0;\">'atan'<\/span>, <span style=\"background-color: #fff0f0;\">'atan2'<\/span>, <span style=\"background-color: #fff0f0;\">'atanh'<\/span>, <span style=\"background-color: #fff0f0;\">'ceil'<\/span>, \r\n<span style=\"background-color: #fff0f0;\">'copysign'<\/span>, <span style=\"background-color: #fff0f0;\">'cos'<\/span>, <span style=\"background-color: #fff0f0;\">'cosh'<\/span>, <span style=\"background-color: #fff0f0;\">'degrees'<\/span>, <span style=\"background-color: #fff0f0;\">'e'<\/span>, <span style=\"background-color: #fff0f0;\">'erf'<\/span>, <span style=\"background-color: #fff0f0;\">'erfc'<\/span>, <span style=\"background-color: #fff0f0;\">'exp'<\/span>, \r\n<span style=\"background-color: #fff0f0;\">'expm1'<\/span>, <span style=\"background-color: #fff0f0;\">'fabs'<\/span>, <span style=\"background-color: #fff0f0;\">'factorial'<\/span>, <span style=\"background-color: #fff0f0;\">'floor'<\/span>, <span style=\"background-color: #fff0f0;\">'fmod'<\/span>, <span style=\"background-color: #fff0f0;\">'frexp'<\/span>, <span style=\"background-color: #fff0f0;\">'fsum'<\/span>, \r\n<span style=\"background-color: #fff0f0;\">'gamma'<\/span>, <span style=\"background-color: #fff0f0;\">'gcd'<\/span>, <span style=\"background-color: #fff0f0;\">'hypot'<\/span>, <span style=\"background-color: #fff0f0;\">'inf'<\/span>, <span style=\"background-color: #fff0f0;\">'isclose'<\/span>, <span style=\"background-color: #fff0f0;\">'isfinite'<\/span>, <span style=\"background-color: #fff0f0;\">'isinf'<\/span>, \r\n<span style=\"background-color: #fff0f0;\">'isnan'<\/span>, <span style=\"background-color: #fff0f0;\">'ldexp'<\/span>, <span style=\"background-color: #fff0f0;\">'lgamma'<\/span>, <span style=\"background-color: #fff0f0;\">'log'<\/span>, <span style=\"background-color: #fff0f0;\">'log10'<\/span>, <span style=\"background-color: #fff0f0;\">'log1p'<\/span>, <span style=\"background-color: #fff0f0;\">'log2'<\/span>, <span style=\"background-color: #fff0f0;\">'modf'<\/span>, \r\n<span style=\"background-color: #fff0f0;\">'nan'<\/span>, <span style=\"background-color: #fff0f0;\">'pi'<\/span>, <span style=\"background-color: #fff0f0;\">'pow'<\/span>, <span style=\"background-color: #fff0f0;\">'radians'<\/span>, <span style=\"background-color: #fff0f0;\">'sin'<\/span>, <span style=\"background-color: #fff0f0;\">'sinh'<\/span>, <span style=\"background-color: #fff0f0;\">'sqrt'<\/span>, <span style=\"background-color: #fff0f0;\">'tan'<\/span>, \r\n<span style=\"background-color: #fff0f0;\">'tanh'<\/span>, <span style=\"background-color: #fff0f0;\">'tau'<\/span>, <span style=\"background-color: #fff0f0;\">'trunc'<\/span>]\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Note the special variable that begins with double underscore __name__. This is the module&#8217;s name. The other string __file__ is the file name where the module was imported from<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t6\">6. The <em>globals( )<\/em> and the <em>locals( )<\/em> Functions<\/strong><\/h4>\n<p>These two functions are used to return the names in the global and local namespace. Though this depends on the location from where the call is made.<\/p>\n<p>If you call locals() from within a function, then it would return all the names that are accessible locally from that function. However if you call globals() from inside a function, then it would return all that are accessible globally from that function.<\/p>\n<p>The return type of globals() and the locals() functions is a dictionary.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t7\">7. The reload() Function<\/strong><\/h4>\n<p>If you import a module into your program, then the code in the top-level part of the module is executed just once. This means that if changes are made to the module, you would not have the updated version of the module.<\/p>\n<p>To solve this you used the reload() function. This function\u00a0 is used to re-execute the top-level code in a module. So you can have the update module. It runs the import statement again. Then syntax for reload() is:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">reload(module)\r\n<\/pre>\n<p>Here, module is the name of the module you want to reload<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A module in Python is a container for codes. So you can defined functions, classes and variables inside a module. Let&#8217;s say you have a &hellip; <\/p>\n","protected":false},"author":395,"featured_media":201,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[17],"class_list":["post-197","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorials","tag-python-modules"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python - Modules - Python Tutorials<\/title>\n<meta name=\"description\" content=\"This lesson explains all you need to know about Python modules. It also covers creating and using modules as well as import statements\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python - Modules - Python Tutorials\" \/>\n<meta property=\"og:description\" content=\"This lesson explains all you need to know about Python modules. It also covers creating and using modules as well as import statements\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-08T05:31:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-02T03:56:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Modules-in-Python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1005\" \/>\n\t<meta property=\"og:image:height\" content=\"544\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Python &#8211; Modules\",\"datePublished\":\"2019-02-08T05:31:39+00:00\",\"dateModified\":\"2019-03-02T03:56:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/\"},\"wordCount\":822,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Modules-in-Python.jpg\",\"keywords\":[\"Python Modules\"],\"articleSection\":[\"Python Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/\",\"name\":\"Python - Modules - Python Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Modules-in-Python.jpg\",\"datePublished\":\"2019-02-08T05:31:39+00:00\",\"dateModified\":\"2019-03-02T03:56:06+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"description\":\"This lesson explains all you need to know about Python modules. It also covers creating and using modules as well as import statements\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Modules-in-Python.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Modules-in-Python.jpg\",\"width\":1005,\"height\":544,\"caption\":\"Modules in PYthon\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/17-python-modules\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python &#8211; Modules\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\",\"name\":\"Python Tutorials\",\"description\":\"Python Tutorial for Programming and Data Science\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python - Modules - Python Tutorials","description":"This lesson explains all you need to know about Python modules. It also covers creating and using modules as well as import statements","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/","og_locale":"en_US","og_type":"article","og_title":"Python - Modules - Python Tutorials","og_description":"This lesson explains all you need to know about Python modules. It also covers creating and using modules as well as import statements","og_url":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/","og_site_name":"Python Tutorials","article_published_time":"2019-02-08T05:31:39+00:00","article_modified_time":"2019-03-02T03:56:06+00:00","og_image":[{"width":1005,"height":544,"url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Modules-in-Python.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Python &#8211; Modules","datePublished":"2019-02-08T05:31:39+00:00","dateModified":"2019-03-02T03:56:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/"},"wordCount":822,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Modules-in-Python.jpg","keywords":["Python Modules"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/","url":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/","name":"Python - Modules - Python Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Modules-in-Python.jpg","datePublished":"2019-02-08T05:31:39+00:00","dateModified":"2019-03-02T03:56:06+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"description":"This lesson explains all you need to know about Python modules. It also covers creating and using modules as well as import statements","breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Modules-in-Python.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Modules-in-Python.jpg","width":1005,"height":544,"caption":"Modules in PYthon"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/python\/17-python-modules\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/python\/"},{"@type":"ListItem","position":2,"name":"Python &#8211; Modules"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/python\/#website","url":"https:\/\/www.kindsonthegenius.com\/python\/","name":"Python Tutorials","description":"Python Tutorial for Programming and Data Science","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/python\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":2,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/197\/revisions\/202"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media\/201"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}