-
Notifications
You must be signed in to change notification settings - Fork 0
/
potential-pythonic-pitfalls.html
74 lines (72 loc) · 26.4 KB
/
potential-pythonic-pitfalls.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html> <head lang=en><meta charset=UTF-8><title>Potential Pythonic Pitfalls | EF</title><link href=//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css rel=stylesheet><link href=http://fonts.googleapis.com/css?family=Inconsolata rel=stylesheet type=text/css><link rel=stylesheet href=http://nafiulis.me/theme/css/main.css><link rel=stylesheet href=http://nafiulis.me/theme/css/pygment.css><script src=http://nafiulis.me/theme/js/jquery.min.js></script><script src=http://nafiulis.me/theme/js/main.js></script></head> <body> <!--Heading at the top saying "Engineering Fantasy"--> <div id=header_top> <div class=title> <a href=http://nafiulis.me><span id=engineering>Engineering</span><span id=fantasy>Fantasy</span></a> </div> </div> <button type=button class="js-menu-trigger sliding-menu-button button-nav"> <img src=https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/menu-white.png alt="Menu Icon"> </button> <!--Navigation Bar--> <nav class="js-menu sliding-menu-content"> <span class=section-header>Pages</span> <ul> <li><a href=http://nafiulis.me>Home</a></li> <li><a href=http://nafiulis.me/tags.html>Tags</a></li> <li><a href=http://nafiulis.me/pages/about-me.html>About Me</a></li> </ul> <span class=section-header>Categories</span> <ul> <li><a href=http://nafiulis.me/category/anime.html>Anime</a></li> <li><a href=http://nafiulis.me/category/education.html>Education</a></li> <li><a href=http://nafiulis.me/category/productivity.html>Productivity</a></li> <li><a href=http://nafiulis.me/category/programming.html>programming</a></li> <li><a href=http://nafiulis.me/category/rants.html>rants</a></li> </ul> </nav> <div class="js-menu-screen menu-screen"></div> <!--Main Container--> <div class=container> <!--Top most menu--> <div id=menu> <div class=left> <a href=http://nafiulis.me/feeds/all.atom.xml><i class="fa fa-rss
icon"></i></a> <a href=https://twitter.com/gamesbrainiac><i class="fa fa-twitter icon"></i></a> </div> <div class=center> <h1 class=message>Nafiul Islam on casting spells with code</h1> </div> <div class=right> <a href=https://github.com/gamesbrainiac><i class="fa fa-github icon"></i></a> <a href=http://stackoverflow.com/users/1624921/games-brainiac><i class="fa fa-stack-overflow icon" style="padding-right: 30px"></i></a> </div> </div> <!--Main blog list container--> <div id=blogroll> <div class=article-container> <h1>Potential Pythonic Pitfalls</h1> <p class=time>Monday, 11 May 2015</p> <div class=article-content> <div class="contents topic" id=table-of-contents> <p class="topic-title first">Table of Contents</p> <ul class=simple> <li><a class="reference internal" href=#not-knowing-the-python-version id=id7>Not Knowing the Python Version</a></li> <li><a class="reference internal" href=#obsessing-over-one-liners id=id8>Obsessing Over One-Liners</a></li> <li><a class="reference internal" href=#initializing-a-set-the-wrong-way id=id9>Initializing a set the Wrong Way</a></li> <li><a class="reference internal" href=#misunderstanding-the-gil id=id10>Misunderstanding the GIL</a></li> <li><a class="reference internal" href=#using-old-style-classes id=id11>Using Old Style Classes</a></li> <li><a class="reference internal" href=#iterating-the-wrong-way id=id12>Iterating the Wrong Way</a></li> <li><a class="reference internal" href=#using-mutable-default-arguments id=id13>Using Mutable Default Arguments</a></li> <li><a class="reference internal" href=#takeaway id=id14>Takeaway</a></li> <li><a class="reference internal" href=#update id=id15>Update</a></li> </ul> </div> <p>Python is a very expressive language. It provides us with a large standard library and many builtins to get the job done quickly. However, many can get lost in the power that it provides, fail to make full use of the standard library, value one liners over clarity and misunderstand its basic constructs. This is a non-exhaustive list of a few of the pitfalls programmers new to Python fall into.</p> <div class=section id=not-knowing-the-python-version> <h2><a class=toc-backref href=#id7>Not Knowing the Python Version</a></h2> <p>This is a recurring problem in StackOverflow questions. Many write perfectly working code for one version but they have a <em>different</em> version of Python installed on their system.<a class=footnote-reference href=#pythree id=id1>[1]</a> Make sure that you know the Python version you're working with. You can check via the following:</p> <div class=highlight><pre><span></span>$ python --version
Python <span class=m>2</span>.7.9
</pre></div> <div class=section id=not-using-a-version-manager> <h3>Not Using a Version Manager</h3> <p><a class="reference external" href=https://github.com/yyuu/pyenv>pyenv</a> is a great tool for managing different Python versions. Unfortunately, it only works on *nix systems. On Mac OS, one can simply install it via <code>brew install pyenv</code> and on Linux, there is an <a class="reference external" href=https://github.com/yyuu/pyenv-installer>automatic installer</a>. <a class=footnote-reference href=#alternative id=id2>[2]</a></p> </div> </div> <div class=section id=obsessing-over-one-liners> <h2><a class=toc-backref href=#id8>Obsessing Over One-Liners</a></h2> <p>Some get a <em>real kick</em> out of one liners. Many boast about their one-liner solutions even if they are less efficient than a multi-line solution.</p> <p>What this essentially means in Python is convoluted comprehensions having multiple expressions. For example:</p> <div class=highlight><pre><span></span><span class=n>l</span> <span class=o>=</span> <span class=p>[</span><span class=n>m</span> <span class=k>for</span> <span class=n>a</span><span class=p>,</span> <span class=n>b</span> <span class=ow>in</span> <span class=nb>zip</span><span class=p>(</span><span class=n>this</span><span class=p>,</span> <span class=n>that</span><span class=p>)</span> <span class=k>if</span> <span class=n>b</span><span class=o>.</span><span class=n>method</span><span class=p>(</span><span class=n>a</span><span class=p>)</span> <span class=o>!=</span> <span class=n>b</span> <span class=k>for</span> <span class=n>m</span> <span class=ow>in</span> <span class=n>b</span> <span class=k>if</span> <span class=ow>not</span> <span class=n>m</span><span class=o>.</span><span class=n>method</span><span class=p>(</span><span class=n>a</span><span class=p>,</span> <span class=n>b</span><span class=p>)</span> <span class=ow>and</span> <span class=nb>reduce</span><span class=p>(</span><span class=k>lambda</span> <span class=n>x</span><span class=p>,</span> <span class=n>y</span><span class=p>:</span> <span class=n>a</span> <span class=o>+</span> <span class=n>y</span><span class=o>.</span><span class=n>method</span><span class=p>(),</span> <span class=p>(</span><span class=n>m</span><span class=p>,</span> <span class=n>a</span><span class=p>,</span> <span class=n>b</span><span class=p>))]</span>
</pre></div> <p>To be perfectly honest, I made the above example up. But, I've seen plenty of people write code like it. Code like this will make no sense in a week's time. If you're trying to do something a little more complex that simply adding an item to a <code>list</code> or <code>set</code> with a condition then you're probably making a mistake.</p> <p>One-Liners are not achievements, yes they can seem very clever but they are not achievements. Its like thinking that shoving everything into your closet is an actual attempt at cleaning your room. Good code is clean, easy to read and efficient.</p> </div> <div class=section id=initializing-a-set-the-wrong-way> <h2><a class=toc-backref href=#id9>Initializing a set the Wrong Way</a></h2> <p>This is a more subtle problem that can catch you off guard. <code>set</code> comprehensions are a lot like list comprehensions.</p> <div class=highlight><pre><span></span><span class=o>>>></span> <span class=p>{</span> <span class=n>n</span> <span class=k>for</span> <span class=n>n</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=mi>10</span><span class=p>)</span> <span class=k>if</span> <span class=n>n</span> <span class=o>%</span> <span class=mi>2</span> <span class=o>==</span> <span class=mi>0</span> <span class=p>}</span>
<span class=p>{</span><span class=mi>0</span><span class=p>,</span> <span class=mi>8</span><span class=p>,</span> <span class=mi>2</span><span class=p>,</span> <span class=mi>4</span><span class=p>,</span> <span class=mi>6</span><span class=p>}</span>
<span class=o>>>></span> <span class=nb>type</span><span class=p>({</span> <span class=n>n</span> <span class=k>for</span> <span class=n>n</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=mi>10</span><span class=p>)</span> <span class=k>if</span> <span class=n>n</span> <span class=o>%</span> <span class=mi>2</span> <span class=o>==</span> <span class=mi>0</span> <span class=p>})</span>
<span class=o><</span><span class=k>class</span> <span class=err>'</span><span class=nc>set</span><span class=s1>'></span>
</pre></div> <p>The above is one such example of a set comprehension. Sets are like lists in that they are containers. The difference is that a set cannot have any duplicate values and sets are unordered. Seeing set comprehensions people often make the mistake of thinking that <code>{}</code> initializes an <em>empty</em> set. It does not, it initializes an empty <em>dict</em>.</p> <div class=highlight><pre><span></span><span class=o>>>></span> <span class=p>{}</span>
<span class=p>{}</span>
<span class=o>>>></span> <span class=nb>type</span><span class=p>({})</span>
<span class=o><</span><span class=k>class</span> <span class=err>'</span><span class=nc>dict</span><span class=s1>'></span>
</pre></div> <p>If we wish to initialize an empty set, then we simply call <code>set()</code>.</p> <div class=highlight><pre><span></span><span class=o>>>></span> <span class=nb>set</span><span class=p>()</span>
<span class=nb>set</span><span class=p>()</span>
<span class=o>>>></span> <span class=nb>type</span><span class=p>(</span><span class=nb>set</span><span class=p>())</span>
<span class=o><</span><span class=k>class</span> <span class=err>'</span><span class=nc>set</span><span class=s1>'></span>
</pre></div> <p>Note how an empty set is denoted as <code>set()</code> but a set containing something is denoted as items surrounded by curly braces.</p> <div class=highlight><pre><span></span><span class=o>>>></span> <span class=n>s</span> <span class=o>=</span> <span class=nb>set</span><span class=p>()</span>
<span class=o>>>></span> <span class=n>s</span>
<span class=nb>set</span><span class=p>()</span>
<span class=o>>>></span> <span class=n>s</span><span class=o>.</span><span class=n>add</span><span class=p>(</span><span class=mi>1</span><span class=p>)</span>
<span class=o>>>></span> <span class=n>s</span>
<span class=p>{</span><span class=mi>1</span><span class=p>}</span>
<span class=o>>>></span> <span class=n>s</span><span class=o>.</span><span class=n>add</span><span class=p>(</span><span class=mi>2</span><span class=p>)</span>
<span class=o>>>></span> <span class=n>s</span>
<span class=p>{</span><span class=mi>1</span><span class=p>,</span> <span class=mi>2</span><span class=p>}</span>
</pre></div> <p>This is rather counter intuitive, since you'd expect something like <code>set([1, 2])</code>.</p> </div> <div class=section id=misunderstanding-the-gil> <h2><a class=toc-backref href=#id10>Misunderstanding the GIL</a></h2> <p>The GIL (Global Interpreter Lock) means that only one thread in a Python program can be running at any one time. This implies that when we create a thread and expect to run in <em>parallel</em> it doesn't. What the Python interpreter is actually doing is quickly <em>switching</em> between different running threads. But this is an oversimplified version of what is actually happening. There are many instances in which things <em>do</em> run in parallel, like when using libraries that are essentially C extensions. But when running Python code, you don't get parallel execution <em>most</em> of the time. In other words, threads in Python are not like Threads in Java or C++.</p> <p>Many will try to defend Python by saying that these are <em>real</em> threads.<a class=footnote-reference href=#realthreads id=id3>[3]</a> This is indeed true, but does not change the fact that how Python handles threads is different from what you'd generally expect. This is the same case for a language like Ruby (which also has an interpreter lock).</p> <p>The prescribed solution to this is using the <code>multiprocessing</code> module. The <code>multiprocessing</code> module provides you with the <code>Process</code> class which is basically a nice cover over a fork. However, a fork is much more expensive than a thread, so you might not always see the performance benefits since now the different processes have to do a lot of work to co-ordinate with each other.</p> <p>However, this problem does not exist every <em>implementation</em> of Python. <a class="reference external" href=http://pypy.readthedocs.org/en/latest/stm.html>PyPy-stm</a> for example is an implementation of Python that tries to get rid of the GIL (still not stable yet). Implementations built on top of other platforms like the JVM (Jython) or CLR (IronPython) do not have GIL problems.</p> <p>All in all, be careful when using the <code>Thread</code> class, what you get might not be what you expect.</p> </div> <div class=section id=using-old-style-classes> <h2><a class=toc-backref href=#id11>Using Old Style Classes</a></h2> <p>In Python 2 there are two types of classes, there's the "old style" classes, and there's the "new style" classes. If you're using Python 3, then you're using the "new style" classes by default. In order to make sure that you're using "new style" classes in Python 2, you need to inherit from <code>object</code> for <em>any</em> new class you create that isn't already inheriting from a builtin like <code>int</code> or <code>list</code>. In other words, your base class, the class that isn't inheriting from anything else, should always inherit from object.</p> <div class=highlight><pre><span></span><span class=k>class</span> <span class=nc>MyNewObject</span><span class=p>(</span><span class=nb>object</span><span class=p>):</span>
<span class=c1># stuff here</span>
</pre></div> <p>These "new style" classes fix some very fundamental flaws in the old style classes that we really don't need to get into. However, if anyone is interested they can find the information in the <a class="reference external" href=https://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes>related documentation</a>.</p> </div> <div class=section id=iterating-the-wrong-way> <h2><a class=toc-backref href=#id12>Iterating the Wrong Way</a></h2> <p>Its very common to see the following code from users who are relatively new to the language:</p> <div class=highlight><pre><span></span><span class=k>for</span> <span class=n>name_index</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=nb>len</span><span class=p>(</span><span class=n>names</span><span class=p>)):</span>
<span class=k>print</span><span class=p>(</span><span class=n>names</span><span class=p>[</span><span class=n>name_index</span><span class=p>])</span>
</pre></div> <p>There is no need to call <code>len</code> in the above example, since iterating over the list is actually much simpler:</p> <div class=highlight><pre><span></span><span class=k>for</span> <span class=n>name</span> <span class=ow>in</span> <span class=n>names</span><span class=p>:</span>
<span class=k>print</span><span class=p>(</span><span class=n>name</span><span class=p>)</span>
</pre></div> <p>Furthermore, there are a whole host of other tools at your disposal to make iteration easier. For example, <code>zip</code> can be used to iterate over two lists at once:<a class=footnote-reference href=#zip id=id4>[4]</a></p> <div class=highlight><pre><span></span><span class=k>for</span> <span class=n>cat</span><span class=p>,</span> <span class=n>dog</span> <span class=ow>in</span> <span class=nb>zip</span><span class=p>(</span><span class=n>cats</span><span class=p>,</span> <span class=n>dogs</span><span class=p>):</span>
<span class=k>print</span><span class=p>(</span><span class=n>cat</span><span class=p>,</span> <span class=n>dog</span><span class=p>)</span>
</pre></div> <p>If we want to take into consideration both the index <em>and</em> the value list variable, we can use <code>enumerate</code>:<a class=footnote-reference href=#enumerate id=id5>[5]</a></p> <div class=highlight><pre><span></span><span class=k>for</span> <span class=n>index</span><span class=p>,</span> <span class=n>cat</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>cats</span><span class=p>):</span>
<span class=k>print</span><span class=p>(</span><span class=n>cat</span><span class=p>,</span> <span class=n>index</span><span class=p>)</span>
</pre></div> <p>There are also many useful functions to choose from in <a class="reference external" href=https://docs.python.org/3/library/itertools.html>itertools</a>. Please note however, that using <code>itertools</code> functions is not always the right choice. If one of the functions in <code>itertools</code> offers a very convenient solution to the problem you're trying to solve, like flattening a list or creating a getting the permutations of the contents of a given list, then go for it. But <em>don't</em> try to fit it into some part of your code just because you want to.</p> <p>The problem with <code>itertools</code> abuse happens so often that one highly respected Python contributor on StackOverflow has dedicated a significant part of their profile to it.<a class=footnote-reference href=#abarnert id=id6>[6]</a></p> </div> <div class=section id=using-mutable-default-arguments> <h2><a class=toc-backref href=#id13>Using Mutable Default Arguments</a></h2> <p>I've seen the following quite a lot:</p> <div class=highlight><pre><span></span><span class=k>def</span> <span class=nf>foo</span><span class=p>(</span><span class=n>a</span><span class=p>,</span> <span class=n>b</span><span class=p>,</span> <span class=n>c</span><span class=o>=</span><span class=p>[]):</span>
<span class=c1># append to c</span>
<span class=c1># do some more stuff</span>
</pre></div> <p>Never use mutable default arguments, instead use the following:</p> <div class=highlight><pre><span></span><span class=k>def</span> <span class=nf>foo</span><span class=p>(</span><span class=n>a</span><span class=p>,</span> <span class=n>b</span><span class=p>,</span> <span class=n>c</span><span class=o>=</span><span class=bp>None</span><span class=p>):</span>
<span class=k>if</span> <span class=n>c</span> <span class=ow>is</span> <span class=bp>None</span><span class=p>:</span>
<span class=n>c</span> <span class=o>=</span> <span class=p>[]</span>
<span class=c1># append to c</span>
<span class=c1># do some more stuff</span>
</pre></div> <p>Instead of explaining what the problem is, its better to show the effects of using mutable default arguments:</p> <div class=highlight><pre><span></span><span class=n>In</span><span class=p>[</span><span class=mi>2</span><span class=p>]:</span> <span class=k>def</span> <span class=nf>foo</span><span class=p>(</span><span class=n>a</span><span class=p>,</span> <span class=n>b</span><span class=p>,</span> <span class=n>c</span><span class=o>=</span><span class=p>[]):</span>
<span class=o>...</span> <span class=n>c</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=n>a</span><span class=p>)</span>
<span class=o>...</span> <span class=n>c</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=n>b</span><span class=p>)</span>
<span class=o>...</span> <span class=k>print</span><span class=p>(</span><span class=n>c</span><span class=p>)</span>
<span class=o>...</span>
<span class=n>In</span><span class=p>[</span><span class=mi>3</span><span class=p>]:</span> <span class=n>foo</span><span class=p>(</span><span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>)</span>
<span class=p>[</span><span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>]</span>
<span class=n>In</span><span class=p>[</span><span class=mi>4</span><span class=p>]:</span> <span class=n>foo</span><span class=p>(</span><span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>)</span>
<span class=p>[</span><span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>]</span>
<span class=n>In</span><span class=p>[</span><span class=mi>5</span><span class=p>]:</span> <span class=n>foo</span><span class=p>(</span><span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>)</span>
<span class=p>[</span><span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>,</span> <span class=mi>1</span><span class=p>]</span>
</pre></div> <dl class=docutils> <dt>The same <code>c</code> is being referenced again and again every time the function is called. This can have some very</dt> <dd>unwanted consequences.</dd> </dl> </div> <div class=section id=takeaway> <h2><a class=toc-backref href=#id14>Takeaway</a></h2> <p>These are just some of the problems that one might run into when relatively new at Python. Please note however, that this is far from a comprehensive list of the problems that one might run into. The other pitfalls however are largely to do with people using Python like Java or C++ and trying to use Python in a way that they are familiar with. So, as a continuation of this, try diving into things like Python's <code>super</code> function. Take a look at <code>classmethod</code>, <code>staticmethod</code> and <code>__slots__</code>.</p> </div> <div class=section id=update> <h2><a class=toc-backref href=#id15>Update</a></h2> <p><em>Last Updated on 12 May 2015 4:50 PM (GMT +6)</em></p> <ul class=simple> <li>Made the section on <a class="reference internal" href=#misunderstanding-the-gil>Misunderstanding the GIL</a> better.</li> </ul> <hr class=docutils> <table class="docutils footnote" frame=void id=pythree rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id1>[1]</a></td><td>Most people are taught Python using Python 2. However, when they go home and try things out themselves, they install Python 3 (quite a natural thing to install the <em>latest</em> version).</td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=alternative rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id2>[2]</a></td><td><a class="reference external" href=http://saghul.github.io/pythonz/ >pythonz</a> is an alternative to Pyenv thats worth checking out if pyenv doesn't work for you.</td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=realthreads rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id3>[3]</a></td><td>When people talk about <em>real</em> threads what they essentially mean is that these threads are real CPU threads, which are scheduled by the OS (Operating System).</td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=zip rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id4>[4]</a></td><td><a class="reference external" href=https://docs.python.org/3/library/functions.html#zip>https://docs.python.org/3/library/functions.html#zip</a></td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=enumerate rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id5>[5]</a></td><td><code>enumerate</code> can be further configured to produce the kind of index you want. <a class="reference external" href=https://docs.python.org/3/library/functions.html#enumerate>https://docs.python.org/3/library/functions.html#enumerate</a></td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=abarnert rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id6>[6]</a></td><td><a class="reference external" href=http://stackoverflow.com/users/908494/abarnert>http://stackoverflow.com/users/908494/abarnert</a></td></tr> </tbody> </table> </div> </div> </div> <div class=post-meta><span class=meta-type>Category: </span> <span><a href=http://nafiulis.me/category/programming.html>Programming</a></span> <span class=meta-type> Tags: </span> <span> <a href=http://nafiulis.me/tag/python.html>python</a>, <a href=http://nafiulis.me/tag/problems.html>problems</a> </span> </div> <div id=disqus_thread style="margin-top: 10px; margin-left: 20px; margin-right: 20px;"></div> <script type=text/javascript>
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'nafiulisme'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script> <noscript>Please enable JavaScript to view the <a href=http://disqus.com/?ref_noscript>comments powered by Disqus.</a></noscript> </div> <!--Footer--> <div id=footer> <footer> Code examples licenced under MIT License <br> Copyright <i class="fa fa-copyright"></i> 2018 Quazi Nafiul Islam </footer> </div> </div> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-55554110-1', 'auto');
ga('send', 'pageview');
</script> </body> </html>