<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: tortellini</title>
    <description>The latest articles on DEV Community by tortellini (@tortellini).</description>
    <link>https://dev.to/tortellini</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F280449%2Fff0fa667-9fe7-4d16-8aa2-0eec47aae26d.png</url>
      <title>DEV Community: tortellini</title>
      <link>https://dev.to/tortellini</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tortellini"/>
    <language>en</language>
    <item>
      <title>Unconventional hobbies during quarantine!</title>
      <dc:creator>tortellini</dc:creator>
      <pubDate>Thu, 16 Apr 2020 18:52:54 +0000</pubDate>
      <link>https://dev.to/tortellini/unconventional-hobbies-during-quarantine-3mo4</link>
      <guid>https://dev.to/tortellini/unconventional-hobbies-during-quarantine-3mo4</guid>
      <description>&lt;h1&gt;
  
  
  With the world on lockdown:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Comment something (&lt;strong&gt;&lt;em&gt;unconventional&lt;/em&gt;&lt;/strong&gt;) worth learning/exploring/killing-time &lt;strong&gt;(non-dev related)&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Origami&lt;/li&gt;
&lt;li&gt;Card stacking&lt;/li&gt;
&lt;li&gt;Type racing&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Note:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;I will try to keep this list as up-to date as possible with comments below 👍&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>hobbies</category>
      <category>fun</category>
      <category>quarantine</category>
    </item>
    <item>
      <title>Careful when using Python Generators!</title>
      <dc:creator>tortellini</dc:creator>
      <pubDate>Fri, 20 Mar 2020 02:59:14 +0000</pubDate>
      <link>https://dev.to/tortellini/careful-when-using-python-generators-2a0p</link>
      <guid>https://dev.to/tortellini/careful-when-using-python-generators-2a0p</guid>
      <description>&lt;h1&gt;
  
  
  Yes, they are memory efficient!
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Python generators may prove themselves extremely useful in cases when you have large amounts of data and are trying to feed it to an iterator. In short, generators return a lazy iterator that does not store their contents in memory. WOW! Great, sounds like you save yourself the trouble of running into a &lt;code&gt;MemoryError&lt;/code&gt;, right?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  But, they hide something...
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000000000000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;4.&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# What do you think is the output of the above for loop?
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Generators are hungry hungry!
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;When iterating over a generator, the elements at each location are essentially being "consumed" and "discarded".&lt;/li&gt;
&lt;li&gt;In other words, if you try to iterate AGAIN over the generator, it will look like all of your elements vanished!&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Answer to the code above:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;You will see no numbers printed to the console.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Leave your comments below!
&lt;/h2&gt;

</description>
      <category>python</category>
      <category>generators</category>
      <category>trick</category>
    </item>
  </channel>
</rss>
