<?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: Rattlingshinuiba</title>
    <description>The latest articles on DEV Community by Rattlingshinuiba (@rattlingshinuiba).</description>
    <link>https://dev.to/rattlingshinuiba</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%2F162036%2Fe786341d-175e-4fe2-bd09-3ffe77453409.gif</url>
      <title>DEV Community: Rattlingshinuiba</title>
      <link>https://dev.to/rattlingshinuiba</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rattlingshinuiba"/>
    <language>en</language>
    <item>
      <title>Debug puppeteer in an interactive way</title>
      <dc:creator>Rattlingshinuiba</dc:creator>
      <pubDate>Sun, 05 Jan 2020 14:15:24 +0000</pubDate>
      <link>https://dev.to/rattlingshinuiba/debug-puppeteer-in-an-interactive-way-69j</link>
      <guid>https://dev.to/rattlingshinuiba/debug-puppeteer-in-an-interactive-way-69j</guid>
      <description>&lt;p&gt;Recently I play around with Puppeteer as an attempt to build a simple back-end service. Puppeteer is an awesome tool to emulate the browser's behaviors, which makes web scraping possible. It is sponsored by Google, and Javascript has more strong ties to HTML document(that is, the crawler's target) than Python does, though Python is a friendly language to get your feet wet. &lt;/p&gt;

&lt;p&gt;As the title suggests, I would like to show you how to debug puppeteer just like the way we use &lt;u&gt;Ipython or Jupyter notebooks&lt;/u&gt;. &lt;/p&gt;

&lt;p&gt;I pretty like &lt;strong&gt;debug-driven learning&lt;/strong&gt; which offers an overview of a particular object or function. For Javascript, there is console in the browser to meet my need, but when we run or debug puppeteer-based script, we might not know the way to access puppeteer's API in browser's console. &lt;/p&gt;

&lt;p&gt;After I messed around with it, I discovered the &lt;code&gt;node --inspect&lt;/code&gt; option which would &lt;strong&gt;add a node logo in devtools&lt;/strong&gt; if you run your script with headless mode turned off. &lt;/p&gt;

&lt;p&gt;Therefore, if you &lt;code&gt;console.log(page)&lt;/code&gt;(page is an object representing the page in the browser) in the script, run it with &lt;code&gt;--inspect&lt;/code&gt; option and click the node logo in the devtools, you would see the page object in the console and in turn you can access its API. For me, it is enough to learn puppeteer step by step.&lt;/p&gt;

&lt;p&gt;Basically, the simple steps are as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;puppeteer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;puppeteer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;browser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;puppeteer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;launch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;newPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// And you can access the page object in the browser console if you follow the steps I specified above.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>Google Keywords When I Learn Programming</title>
      <dc:creator>Rattlingshinuiba</dc:creator>
      <pubDate>Wed, 27 Nov 2019 08:05:10 +0000</pubDate>
      <link>https://dev.to/rattlingshinuiba/google-keywords-when-i-learn-programming-5gfg</link>
      <guid>https://dev.to/rattlingshinuiba/google-keywords-when-i-learn-programming-5gfg</guid>
      <description>&lt;p&gt;Sometimes you can not wrap your head around concepts from official doc when you just wanna try it out.&lt;/p&gt;

&lt;p&gt;Sometimes you are confused when people are engaged in lively conversations in the post or comments.&lt;/p&gt;

&lt;p&gt;Sometimes you google a topic and jargon pops up one after another.&lt;/p&gt;

&lt;p&gt;Isn't there a simplified version of page where author talk with you, not explaining something with terminology from another world?&lt;/p&gt;

&lt;p&gt;Seeking answers, I've been collecting these keywords whenever I wanna learn something without fuss.&lt;/p&gt;

&lt;p&gt;Note that we can understand concepts more deeply in official doc after we grasp basics of them. So official doc is pretty important. After all, some docs are also awesome for us to learn something quickly. &lt;/p&gt;

&lt;p&gt;p.s. Following list is not limited to programming.&lt;/p&gt;

&lt;h4&gt;
  
  
  Get an overview of a subject to get your feet wet
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;basics&lt;/li&gt;
&lt;li&gt;introduction&lt;/li&gt;
&lt;li&gt;starter/beginner

&lt;ul&gt;
&lt;li&gt;get started in xxx&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;learn xxx in x minutes&lt;/li&gt;
&lt;li&gt;learn xxx the right way&lt;/li&gt;
&lt;li&gt;glossary/terminology&lt;/li&gt;
&lt;li&gt;ipynb/notebook&lt;/li&gt;
&lt;li&gt;hello world&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Learn a concept quickly
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;explained&lt;/li&gt;
&lt;li&gt;understand&lt;/li&gt;
&lt;li&gt;⭐eli5

&lt;ul&gt;
&lt;li&gt;Reddit has many eli5-related threads. So does dev.to!&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;visualize

&lt;ul&gt;
&lt;li&gt;If you struggle to understand git commands, you can learn it visually.&lt;/li&gt;
&lt;li&gt;There is an awesome project for algorithm visualization.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;layman&lt;/li&gt;
&lt;li&gt;⭐gist&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Miscellaneous
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;curated&lt;/li&gt;
&lt;li&gt;best practices&lt;/li&gt;
&lt;li&gt;project&lt;/li&gt;
&lt;li&gt;hands-on&lt;/li&gt;
&lt;li&gt;hand book&lt;/li&gt;
&lt;li&gt;hitchhiker&lt;/li&gt;
&lt;li&gt;intuitive&lt;/li&gt;
&lt;li&gt;roadmap&lt;/li&gt;
&lt;li&gt;guide&lt;/li&gt;
&lt;li&gt;⭐blog

&lt;ul&gt;
&lt;li&gt;There are a ton of personal blogs waiting for you to find!&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;⭐101&lt;/li&gt;
&lt;li&gt;⭐cheatsheet

&lt;ul&gt;
&lt;li&gt;You can revise something quickly with cheatsheet.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;step by step&lt;/li&gt;
&lt;li&gt;end to end&lt;/li&gt;
&lt;li&gt;from scratch&lt;/li&gt;
&lt;li&gt;template&lt;/li&gt;
&lt;li&gt;boilerplate&lt;/li&gt;
&lt;li&gt;review&lt;/li&gt;
&lt;li&gt;crash course&lt;/li&gt;
&lt;li&gt;infographic&lt;/li&gt;
&lt;li&gt;snippets&lt;/li&gt;
&lt;li&gt;kit
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  bonus-tips
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Check out image tab in google search results to visualize something.&lt;/li&gt;
&lt;li&gt;Make sure you know exactly what are you gonna search for before you dive into a concept.&lt;/li&gt;
&lt;li&gt;⭐Type &lt;code&gt;thank&lt;/code&gt;, &lt;code&gt;work&lt;/code&gt;, or &lt;code&gt;solve&lt;/code&gt; in &lt;code&gt;CTRL+F&lt;/code&gt; input field in a community question thread.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;save my day&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;awesome&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kaggle&lt;/code&gt; and &lt;code&gt;datacamp&lt;/code&gt; is awesome places to find nice tutorials for data science.&lt;/li&gt;
&lt;li&gt;⭐xxx site:github.io&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Explain Offset in CSS Like I'm Five</title>
      <dc:creator>Rattlingshinuiba</dc:creator>
      <pubDate>Wed, 06 Nov 2019 03:13:24 +0000</pubDate>
      <link>https://dev.to/rattlingshinuiba/explain-offset-in-css-like-i-m-five-3872</link>
      <guid>https://dev.to/rattlingshinuiba/explain-offset-in-css-like-i-m-five-3872</guid>
      <description>&lt;p&gt;Hello there! I have come across this term &lt;code&gt;offset&lt;/code&gt; in CSS for many times. In my view, I treat it as a way of describing a element &lt;code&gt;position&lt;/code&gt; in box model but I'm not sure whether it's accurate or not. I have googled it but every page seems to assume readers have grasped this concept. Also, I looked it up in dictionary but I hope there is a definition specifically for CSS. Forgive my asking but English is my second language.&lt;br&gt;
Thanks in advance!&lt;/p&gt;

</description>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>Thoughts after I rm my home directory</title>
      <dc:creator>Rattlingshinuiba</dc:creator>
      <pubDate>Tue, 29 Oct 2019 08:09:57 +0000</pubDate>
      <link>https://dev.to/rattlingshinuiba/thoughts-after-i-rm-my-home-directory-5f68</link>
      <guid>https://dev.to/rattlingshinuiba/thoughts-after-i-rm-my-home-directory-5f68</guid>
      <description>&lt;p&gt;Recently I have committed a big mistake: I &lt;code&gt;rm&lt;/code&gt; my home directory. One good aspect of this bad situation is that I have backed up the code directory with &lt;code&gt;borg&lt;/code&gt;. However, my &lt;code&gt;hexo&lt;/code&gt; personal blog is not in the list. To make matters worse, most posts of this blog were stored locally. &lt;/p&gt;

&lt;p&gt;The mess is attributed to a simple command: &lt;code&gt;rm&lt;/code&gt;. Although &lt;code&gt;rm&lt;/code&gt; are usually treated as a source of memes  at which even newbies would smile knowingly, this worst case happened to me. Here is the command which cause a disaster: &lt;code&gt;rm -rf * '/home/&amp;lt;user_name&amp;gt;/.local/share/Trash/files'&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Well, I thought I specified a folder to delete everything(&lt;code&gt;*&lt;/code&gt;) in the absolute path(path in the single quote) and expected so. But my home directory was empty after that. &lt;/p&gt;

&lt;p&gt;There is an another joke when we talk about &lt;code&gt;rm&lt;/code&gt;: You should install &lt;code&gt;adobe&lt;/code&gt; series in your filesystem because it would hold its own against &lt;code&gt;rm&lt;/code&gt; for a while when you delete your &lt;code&gt;/&lt;/code&gt; root stupidly. &lt;/p&gt;

&lt;p&gt;So the conclusion is that you need to &lt;code&gt;rm&lt;/code&gt; files in the current working directory. If not, be aware of &lt;code&gt;*&lt;/code&gt;, like the path you specify in the single quote, is part of argument to tell &lt;code&gt;rm&lt;/code&gt; to delete files. So the command should be &lt;code&gt;rm -rf '/home/&amp;lt;user_name&amp;gt;/.local/share/Trash/files/*'&lt;/code&gt;. I learned this lesson the hard way, and hope you never encounter this kind of issue.&lt;/p&gt;

&lt;p&gt;With hindsight, I think I ought to back up files on a regular basis.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>A use case for decorator in Python: retry a function</title>
      <dc:creator>Rattlingshinuiba</dc:creator>
      <pubDate>Mon, 28 Oct 2019 12:02:33 +0000</pubDate>
      <link>https://dev.to/rattlingshinuiba/a-use-case-for-decorator-in-python-retry-a-function-47h8</link>
      <guid>https://dev.to/rattlingshinuiba/a-use-case-for-decorator-in-python-retry-a-function-47h8</guid>
      <description>&lt;p&gt;Life is short, use Python. Python is easy to learn for newbies like me who desire both functionality and performance without complex logic, until &lt;strong&gt;advanced&lt;/strong&gt; concepts come in front of us including asynchronous programming, descriptor, decorator, among many others. &lt;/p&gt;

&lt;p&gt;Admittedly, I have used these advanced features in the way of importing those awesome open source packages, but I didn't type them very much myself. It's OK to only import packages because we just want functionality and retrieve results without wasting time. &lt;/p&gt;

&lt;p&gt;Beyond these basic needs, however, we sometimes also need to write the same function as the one from certain awesome package for the purpose of learning to deepen our understanding of  programming principles behind these interfaces.&lt;/p&gt;

&lt;p&gt;Let's jump right into the theme of today, decorator.&lt;/p&gt;

&lt;p&gt;Let's take an example when we don't use decorator. There are times when you make a request for response from remote server but failed because your connection to network is not stable. So you might try, say, twice more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;request_something&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;except&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="s"&gt;'Bite the dust!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# try again
&lt;/span&gt;        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;       
&lt;span class="k"&gt;else&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="s"&gt;'Killer Queen failed to do that'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# we failed after 3 attempts
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will try 3 times when &lt;code&gt;request_something()&lt;/code&gt; failed and print a message when it all failed. If you are a fan of jojo you would get the point of these messages but you can just pay attention to the comments if you are not. &lt;/p&gt;

&lt;p&gt;But this code block is not good enough in that we have to duplicate the code around &lt;code&gt;request_something&lt;/code&gt; whenever we make another request.&lt;/p&gt;

&lt;p&gt;Decorator comes to rescue. In this case, we focus on one of its characteristic, reusability. Decorator comes in handy when you are going to modify your definition of a particular function. &lt;/p&gt;

&lt;p&gt;Consider the following example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request_sth&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;wrapper&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;i&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;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;request_sth&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="k"&gt;except&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="s"&gt;'Bite the dust!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# try again
&lt;/span&gt;                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;       
        &lt;span class="k"&gt;else&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="s"&gt;'Killer Queen failed to do that'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# we failed after 3 attempts
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;wrapper&lt;/span&gt;            
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It would be much clearer if we use &lt;code&gt;diff&lt;/code&gt; to see what changes are made:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gi"&gt;+ def retry(request_sth):
+    def wrapper():
&lt;/span&gt;        for i in range(1,4):
            try:
                request_sth()
            except:
                print('Bite the dust!') # try again
                continue
            else:
                break       
        else:
            print('Killer Queen failed to do that') # we failed after 3 attempts
&lt;span class="gi"&gt;+       return wrapper 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To summarize these changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We define a new function called &lt;code&gt;retry&lt;/code&gt; and pass in a function, in this case, &lt;code&gt;request_sth&lt;/code&gt;.

&lt;ul&gt;
&lt;li&gt;It allows to use &lt;code&gt;@retry&lt;/code&gt; syntax to modify a function. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;We define inner function &lt;code&gt;wrapper&lt;/code&gt; and return it. 

&lt;ul&gt;
&lt;li&gt;Why bother? We will talk about it soon.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;The rest of code is the same as  the first code block in this post.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To answer why we define a inner function, we can just test it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;def retry(request_sth):
&lt;/span&gt;&lt;span class="gd"&gt;-    def wrapper():
&lt;/span&gt;        for i in range(1,4):
            try:
                request_sth()
            except:
                print('Bite the dust!') # try again
                continue
            else:
                break       
        else:
            print('Killer Queen failed to do that') # we failed after 3 attempts
&lt;span class="gd"&gt;-       return wrapper 
&lt;/span&gt;&lt;span class="gi"&gt;+ @retry
+ def request_sth():
+   import requests
+   response = requests.get(&amp;lt;url&amp;gt;)
&lt;/span&gt;
request_sth()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After you run it, it will work as expected until we hit the final line &lt;code&gt;request_sth()&lt;/code&gt;, it will raise an error. The code would run normally If we didn't remove these lines I marked as red. Why?&lt;/p&gt;

&lt;p&gt;Under the hood, to put it simply, when we hit lines from &lt;code&gt;@retry&lt;/code&gt; to &lt;code&gt;response = requests.get(&amp;lt;url&amp;gt;)&lt;/code&gt;, an invisible line is executed: &lt;code&gt;request_sth = retry(request_sth)&lt;/code&gt;. If you want to dive deeper into it, I recommend checking out &lt;code&gt;Simple Decorator&lt;/code&gt; section from an awesome article &lt;a href="https://realpython.com/primer-on-python-decorators/"&gt;Primer on Python Decorators&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Reminder: Some lines in code block might not indent properly in &lt;code&gt;diff&lt;/code&gt; view.&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
