{"id":37821,"date":"2016-09-15T12:58:41","date_gmt":"2016-09-15T17:58:41","guid":{"rendered":"https:\/\/kenscourses.com\/tc101fall2016\/?guid=53b6d0ffc4dd1896db1bf6c0bc9ba8ee"},"modified":"2016-09-15T12:58:41","modified_gmt":"2016-09-15T17:58:41","slug":"are-you-a-library-mouse","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/are-you-a-library-mouse\/","title":{"rendered":"ARE YOU A LIBRARY MOUSE?"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"http:\/\/emnl.me\/are-you-a-library-mouse-2\/\"><a href=\"http:\/\/emnl.me\/\">Coding The Future<\/a><\/a><\/em><br \/><\/p>\n<p><img src=\"https:\/\/hd.unsplash.com\/photo-1447023029226-ef8f6b52e3ea\" alt=\"\" title=\"\">Image by <a href=\"https:\/\/unsplash.com\/search\/library?photo=YjVa-F9P9kk\">Dmitrij Paskevic<\/a><\/p>\n\n<p>Hello everyone! Guess what? Partials are over! That means that today we're back on track... And today's topic is libraries, a.k.a. modules in Python.<\/p>\n\n<p>Let's begin by defining modules. <a href=\"https:\/\/www.tutorialspoint.com\/python\/python_modules.htm\">TutorialsPoint<\/a> defines a module as a logical way to \"organize your Python code. Grouping related code into a module makes the code easier to understand and use\".<sup id=\"fnref:1\"><a href=\"http:\/\/emnl.me\/are-you-a-library-mouse-2\/#fn:1\" rel=\"footnote\">1<\/a><\/sup> In short, a module is a separate file where you define functions related to a specific action and then import it to your code. The best thing about it all is that it makes coding less confusing and functions re-usable across several programs!<\/p>\n\n<p>Let's get started!<\/p>\n\n<h4 id=\"creatingamodule\">Creating a module<\/h4>\n\n<p>Creating a module is easy. All you have to do is create a new Python file and define the functions that will belong to that module.<sup id=\"fnref:2\"><a href=\"http:\/\/emnl.me\/are-you-a-library-mouse-2\/#fn:2\" rel=\"footnote\">2<\/a><\/sup> For example, if you wanted to create a module containing all the functions for Tic Tac Toe, you would create a module named tictactoe and define all the functions inside.<\/p>\n\n<h4 id=\"usingamodule\">Using a module<\/h4>\n\n<p>Once you wanted to use the library you just created or downloaded from the internet, the first step would be to import it. In the file where you will use it, type the word <em>import<\/em> followed by the name of the module. Let's say we wanted to import the <em>tictactoe.py<\/em> module we imaginarily created above:<\/p>\n\n<p><code>import tictactoe<\/code><\/p>\n\n<p>That imports the module, but in order to use the functions inside it, you need to call the function by using the name of the module (dot) name of the function. Let's say I wanted to use the <em>newGame<\/em> function within the <em>tictactoe<\/em> module:<\/p>\n\n<p><code>tictactoe.newGame()<\/code><\/p>\n\n<p>That's it for today... I know, that was easy! Happy Mexican Independence Day! ??<\/p>\n\n<p><a href=\"http:\/\/twitter.com\/emamex98\">@emamex98<\/a><\/p>\n\n<p>--<\/p>\n\n<div class=\"footnotes\"><ol><li class=\"footnote\" id=\"fn:1\"><p>Definition by <a href=\"https:\/\/www.tutorialspoint.com\/python\/python_modules.htm\">TutorialsPoint<\/a> <a href=\"http:\/\/emnl.me\/are-you-a-library-mouse-2\/#fnref:1\" title=\"return to article\">\u21a9<\/a><\/p><\/li>\n<li class=\"footnote\" id=\"fn:2\"><p>Tutorial by <a href=\"https:\/\/docs.python.org\/3\/tutorial\/modules.html\">Python Software <!--more--><\/a> <a href=\"http:\/\/emnl.me\/are-you-a-library-mouse-2\/#fnref:2\" title=\"return to article\">\u21a9<\/a><\/p><\/li><\/ol><\/div>\n\n<div id=\"disqus_thread\"><\/div>  \n\n<script type=\"text\/javascript\">  \n    var disqus_shortname = 'emnl-me';\n    var disqus_identifier = 'are-you-a-library-mouse';\n\n    (function() {\n        var dsq = document.createElement('script'); dsq.type = 'text\/javascript'; dsq.async = true;\n        dsq.src = '\/\/' + disqus_shortname + '.disqus.com\/embed.js';\n        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);\n    })();\n<\/script>  \n\n<noscript>Please enable JavaScript to view the <a href=\"http:\/\/disqus.com\/?ref_noscript\">comments powered by Disqus.<\/a><\/noscript>  \n\n<p><a href=\"http:\/\/disqus.com\/\" class=\"dsq-brlink\">comments powered by <span class=\"logo-disqus\">Disqus<\/span><\/a> <\/p>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Coding The Future Image by Dmitrij Paskevic Hello everyone! Guess what? Partials are over! That means that today we&#8217;re back on track&#8230; And today&#8217;s topic is libraries, a.k.a. modules in Python. Let&#8217;s begin by defining modules. TutorialsPoint defines a module as a logical way to &#8220;organize your Python code. Grouping related code &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/are-you-a-library-mouse\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ARE YOU A LIBRARY MOUSE?<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[126,185,186],"class_list":["post-37821","post","type-post","status-publish","format-standard","hentry","category-blogs","category-syndicated","tag-functions","tag-libraries","tag-modules"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=37821"}],"version-history":[{"count":1,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37821\/revisions"}],"predecessor-version":[{"id":37822,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37821\/revisions\/37822"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=37821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=37821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=37821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}