<?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>Forem: bluepaperbirds</title>
    <description>The latest articles on Forem by bluepaperbirds (@bluepaperbirds).</description>
    <link>https://forem.com/bluepaperbirds</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%2F325833%2Fc1c848ba-c394-4181-a34c-977b26f64496.png</url>
      <title>Forem: bluepaperbirds</title>
      <link>https://forem.com/bluepaperbirds</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bluepaperbirds"/>
    <language>en</language>
    <item>
      <title>multiple assignment in Python</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Wed, 13 Jan 2021 23:51:14 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/multiple-assignment-in-python-jcg</link>
      <guid>https://forem.com/bluepaperbirds/multiple-assignment-in-python-jcg</guid>
      <description>&lt;p&gt;hey people what's going on? hope you're doing well.&lt;/p&gt;

&lt;p&gt;i'm going to explain multiple assignment in &lt;a href="https://python.org" rel="noopener noreferrer"&gt;python&lt;/a&gt;, so sit back relax and enjoy the article.&lt;/p&gt;

&lt;p&gt;multiple assignment allows us to assign multiple variables &lt;em&gt;at the same time using one line of code&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;here's an example of us using standard assignment. let's say we have a &lt;a href="https://pythonspot.com/python-variables/" rel="noopener noreferrer"&gt;variable&lt;/a&gt; name and i will set this to a value of my name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tux&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let's say edge equals 21 and how about a variable called attractive?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tux&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;
&lt;span class="n"&gt;attractive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;i think i'm gonna set this to true okay, so we have a bunch of variables and then we can print the value of these variables with some print statements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attractive&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so let's print name age and attractive. so we have name age attractive and as you would expect this prints tux 21 and true.&lt;/p&gt;

&lt;p&gt;now another way in which we could write the same code is to use multiple assignment and this allows usto assign multiple variables at the same time using &lt;strong&gt;one line of code&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff4lffahr56ec6b1j4zi7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff4lffahr56ec6b1j4zi7.jpg" alt="surprised cat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so i'm going to turn all of these lines into comments and this time we will only use one line of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# name = "Tux"
# edge = 21
# attractive = True
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But to do this we're going to list all of our variables separated with a comma so that would be name comma edge comma attractive.&lt;/p&gt;

&lt;p&gt;We will set them equal to those values but in the same order separated by commas so that would be tux comma 21 comma true and this would do the same thing, only using one line of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attractive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tux&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can &lt;a href="https://python-commandments.org/python-print-function/" rel="noopener noreferrer"&gt;print&lt;/a&gt; the variables on one line too&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tux&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Tux&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have a large program or use loops/if statements keep in mind the variable &lt;a href="https://pythonbasics.org/scope/" rel="noopener noreferrer"&gt;scope&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Get all keys and values from json object in Python</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Tue, 12 Jan 2021 16:39:58 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/get-all-keys-and-values-from-json-object-in-python-1b2d</link>
      <guid>https://forem.com/bluepaperbirds/get-all-keys-and-values-from-json-object-in-python-1b2d</guid>
      <description>&lt;p&gt;In this &lt;a href="https://python.org" rel="noopener noreferrer"&gt;Python&lt;/a&gt; tutorial we are going to see how we can get all the keys in this json object and also all the values of the keys.&lt;/p&gt;

&lt;p&gt;okay so let me get started let me take one empty python file &lt;br&gt;
here, so yeah so let me save this file first as example.py. &lt;/p&gt;

&lt;h2&gt;
  
  
  Load json
&lt;/h2&gt;

&lt;p&gt;As it is a json i need to import this package called &lt;strong&gt;json&lt;/strong&gt;. This lets you play around with &lt;a href="https://pythonprogramminglanguage.com/python-json/" rel="noopener noreferrer"&gt;json&lt;/a&gt;. Then it is available in this particular Python file. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Right so take that file path and try to open that with &lt;em&gt;open as json file&lt;/em&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open("C:\\pythonPrograms\\example.json") as jsonFile:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That will do json &lt;a href="https://pythonspot.com/json-encoding-and-decoding-with-python/" rel="noopener noreferrer"&gt;decoding&lt;/a&gt;. Our json file looks like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"emp_details"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"123"&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"345"&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You need to give the file name, so this is my file name. It should have double slashes not the single slash, so once we have this using the json library that we have imported you need to load the json object. Let's go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3rozmhb8m4ik4qa8xgpe.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3rozmhb8m4ik4qa8xgpe.jpg" alt="Let's go" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Get keys and values
&lt;/h2&gt;

&lt;p&gt;Using load function json file, this let me keep it into a variable called data.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jsonFile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Then you have a Python &lt;a href="https://pythonbasics.org/class/" rel="noopener noreferrer"&gt;object&lt;/a&gt;. Now you can get the keys and values. The code below depends on what your json file looks like. In our json file there's a header named emp_details.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

    &lt;span class="n"&gt;jsonData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;emp_details&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;That gives us this code:  &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;test.json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;jsonFile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jsonFile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;jsonData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;emp_details&lt;/span&gt;&lt;span class="sh"&gt;"&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;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;jsonData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;It will output:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'name': 'a', 'id': '123'}
dict_keys(['name', 'id'])
dict_values(['a', '123'])
{'name': 'b', 'id': '345'} 
dict_keys(['name', 'id'])
dict_values(['b', '345'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you want, you can loop over the keys and values inside the loop, to do the formatting.&lt;/p&gt;

&lt;p&gt;Here we use a &lt;a href="https://python-commandments.org/python-for-loop/" rel="noopener noreferrer"&gt;for loop&lt;/a&gt; to iterate over the keys and values. If your json file is small like the one in this example, you don't necessarily have to use a loop.&lt;/p&gt;

&lt;p&gt;That's all :-)&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Python vs Go</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Tue, 12 Jan 2021 14:07:04 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/python-vs-go-28c</link>
      <guid>https://forem.com/bluepaperbirds/python-vs-go-28c</guid>
      <description>&lt;p&gt;what's the difference between the &lt;a href="https://python.org"&gt;Python&lt;/a&gt; programming language and the &lt;a href="https://golang.org/"&gt;Go&lt;/a&gt; programming language and which should&lt;br&gt;
you choose?&lt;/p&gt;
&lt;h2&gt;
  
  
  Speed
&lt;/h2&gt;

&lt;p&gt;Okay sorry there are different areas the first area is &lt;strong&gt;speed&lt;/strong&gt;. So go is based on C++ so it's really fast, it's as fast as C++.&lt;/p&gt;

&lt;p&gt;Python is a bit slower so if you rely on speed then you should take go. Go is compiled&lt;br&gt;
programming language. It is a traditional programming language that is compiled down and then executed in bytecode.&lt;/p&gt;

&lt;p&gt;The Python programming language which is &lt;em&gt;interpreted&lt;/em&gt; so you can quickly try things out so if you want to get paid highly then I recommend a Python.&lt;/p&gt;

&lt;p&gt;In the US, you will get six figures easily. &lt;/p&gt;
&lt;h2&gt;
  
  
  Concurrency
&lt;/h2&gt;

&lt;p&gt;Go is a much younger language released in 2009, Python in 1991 so python is still the 800-pound gorilla with much more experience regarding object orientation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Go is not object orientated&lt;/strong&gt; and Python is object oriented, so it's more useful abstraction in many cases python has like concurrent libraries which execute concurrently.&lt;/p&gt;

&lt;p&gt;If you rely on parallel programming and distributed things then &lt;strong&gt;go&lt;/strong&gt; is much easier it has built-in &lt;strong&gt;concurrency support&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Python does not but you can import it easily with the library. So in memory management Python doesn't let you to customize memory management, so it is like automatic in go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f58WinJm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oxf5tl5r2npfe7agotu5.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f58WinJm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oxf5tl5r2npfe7agotu5.jpeg" alt="computer memory concurrency"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go has some customization features so it's a bit more powerful in memory management for the user.&lt;/p&gt;
&lt;h2&gt;
  
  
  General purpose?
&lt;/h2&gt;

&lt;p&gt;For the programmer, Python is much more popular. It is a really simple programming languages to &lt;a href="https://pythonspot.com"&gt;learn&lt;/a&gt;, ok so how does go look?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello world"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go uses parenthesis and it's different, like a bit like the C++ language with some Python language add-ons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&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;Ok so Go feels like an intermediate between Python and C++. Python yeah it looks very clean there are no parentheses and brackets and so on so it's a bit easier to read I would say. It is easier to write and it's a bit cleaner. For a beginner, I'd say &lt;a href="https://golangr.com/"&gt;Go&lt;/a&gt; is harder to learn.&lt;/p&gt;

&lt;p&gt;The Python programming language dominates for general purpose programming. You can use it for &lt;a href="https://pythonpyqt.com/"&gt;gui programming&lt;/a&gt;, &lt;a href="https://pythonbasics.org/what-is-flask-python/"&gt;web development&lt;/a&gt;, &lt;a href="https://pythonprogramminglanguage.com/python-machine-learning/"&gt;machine learning&lt;/a&gt; and lots of other things.&lt;/p&gt;

&lt;p&gt;Go can be used in many domains, but it's not matured yet in all those domains and lots of software is written in Python.&lt;/p&gt;

</description>
      <category>python</category>
      <category>go</category>
    </item>
    <item>
      <title>Python assign functions and memory address
</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Tue, 12 Jan 2021 13:09:52 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/python-assign-functions-and-memory-address-3on0</link>
      <guid>https://forem.com/bluepaperbirds/python-assign-functions-and-memory-address-3on0</guid>
      <description>&lt;p&gt;Hello what's going on everybody? &lt;/p&gt;

&lt;p&gt;I'm going to show you guys how we can assign a function to a variable in &lt;a href="https://python.org" rel="noopener noreferrer"&gt;Python&lt;/a&gt;. I will show you all how we can assign a function to a variable.&lt;/p&gt;

&lt;p&gt;Now let's say we have a &lt;a href="https://pythonspot.com/functions/" rel="noopener noreferrer"&gt;function&lt;/a&gt; named hello and all we'll do is print the word hello.&lt;/p&gt;

&lt;p&gt;You know to call this function, you would type the name of the function followed by a set of parentheses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hello()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and this will print the word "hello" the set of parentheses that comes after a function's name is the portion that will call the function. If you were to remove that set of parentheses afterwards we would not in fact call that function.&lt;/p&gt;

&lt;p&gt;For simplicity, we'll leave out the &lt;a href="https://python-commandments.org/python-main-function/" rel="noopener noreferrer"&gt;main function&lt;/a&gt; from these examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function memory address?
&lt;/h2&gt;

&lt;p&gt;Now with python python will pretty much treat everything as objects including functions. So there's something i want to show you guys, if i was to print the name of my function hello what will be displayed is the memory address of this function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&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="n"&gt;hello&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="n"&gt;hello&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="mh"&gt;0x7f21d6d4e3a0&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the memory address of where this function is located within my computer's memory and it's in hexadecimal think of it like a street address such as 123 fake street. This is the address of where this function is within my computer's memory and each time that i run this program this number can change as you can see it here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fit33qqw0rouwli37fad3.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fit33qqw0rouwli37fad3.jpeg" alt="computer memory"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now one thing that we could do we could assign this address to a variable let's say hi equals hello and be sure that you're not adding that set of parentheses afterwards because then you would be calling the hello function and returning the result to hi.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hello&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="n"&gt;hello&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="mh"&gt;0x7f21d6d4e3a0&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So hi equals hello no parentheses and if i was to print hi well the address of hello and hi will be at the same memory address both of these numbers are the same now.&lt;/p&gt;

&lt;p&gt;The above function is using a &lt;a href="https://pythonprogramminglanguage.com/functions/" rel="noopener noreferrer"&gt;single return&lt;/a&gt; but this works with &lt;a href="https://pythonbasics.org/multiple-return/" rel="noopener noreferrer"&gt;multiple return&lt;/a&gt; too. So what it will return are two memory addresses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hello&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;14:00&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&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="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="n"&gt;hello&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="mh"&gt;0x7f3db682f3a0&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="mh"&gt;0x7f3db682f430&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Call function
&lt;/h2&gt;

&lt;p&gt;What do you imagine would happen if i was to call the hi function after we assign the memory address of hello to hi well then what we'll end up doing is calling the hello function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; hi()
hello
&amp;gt;&amp;gt;&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though we're listing that we would like to call the hi function even though it doesn't exist so it's as if this hello function has two names you, can either use hello or you can use hi. That's because we're assigning the&lt;br&gt;
memory address of hello to this variable of hi, so we could treat hi as a function.&lt;/p&gt;

&lt;p&gt;It's kind of like an alias where this function has two names.&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>What 's the Golang developer salary in Germany?</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Sun, 10 Jan 2021 12:52:05 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/what-s-the-golang-developer-salary-in-germany-4kh9</link>
      <guid>https://forem.com/bluepaperbirds/what-s-the-golang-developer-salary-in-germany-4kh9</guid>
      <description>&lt;p&gt;In Berlin, Germany there are tech companies with &lt;a href="https://golang.org/"&gt;golang&lt;/a&gt; jobs.&lt;/p&gt;

&lt;p&gt;So what is the average annual salary you can expect?&lt;/p&gt;

&lt;p&gt;It is seventy thousand three hundred seventy five euros (73.175 euros or $89.427). That is gross so &lt;em&gt;before tax&lt;/em&gt; the salary range for golang engineers in Berlin Germany is from 65000 euros per year up to 73175 euros per year.&lt;/p&gt;

&lt;p&gt;This is gross before tax!&lt;/p&gt;

&lt;p&gt;Now the weather you fall on the lower range of that scale or the upper range of that scale well depends on a number of factors. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to get the higher paid job?
&lt;/h2&gt;

&lt;p&gt;I find that the two most important ones are your seniority (something you can't really change) and the financial situation that the company is in (pick the company wisely)&lt;/p&gt;

&lt;p&gt;Your seniority will also depend on a number of factors like the years of experience working as a full-time developer is one thing and you need to have minimum three years of full-time experience to be considered the mid-level in Berlin.&lt;/p&gt;

&lt;p&gt;If you are new to Golang, there's a good &lt;a href="https://golangr.com/"&gt;tutorial&lt;/a&gt; here.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to get a Golang job?
&lt;/h2&gt;

&lt;p&gt;But many companies don't just look at the years of experience some actually look much deeper into the complexity of the systems that you have developed in the past as well as at your ability to write reliable code code that scales and code that is clean.&lt;/p&gt;

&lt;p&gt;The financial situation of the company always depends on a number of factors but the basic ones include is it a privately owned company does it have investors is it an international corporation with headquarters in Berlin or or just Berlin office.&lt;/p&gt;

&lt;h2&gt;
  
  
  Am I eligable?
&lt;/h2&gt;

&lt;p&gt;It's fine if you speak only English, German companies&lt;br&gt;
don't usually require German for their engineering jobs. When you're looking at salaries in Berlin Germany keep in mind that the numbers I shared with you is the base salary so around 60, 70 thousand euros per year.&lt;/p&gt;

&lt;p&gt;If you are from outside of the European Union you will need either a blue card or a regular work permit to start a job in Berlin.&lt;/p&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>10 things about the Ruby programming language</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Sun, 10 Jan 2021 12:38:00 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/10-things-about-the-ruby-programming-language-3c57</link>
      <guid>https://forem.com/bluepaperbirds/10-things-about-the-ruby-programming-language-3c57</guid>
      <description>&lt;p&gt;Ruby is an interpreted, high level, general purpose language.It supports different paradigms like functional procedural and object-oriented.&lt;/p&gt;

&lt;p&gt;From the &lt;a href="https://www.ruby-lang.org/en/"&gt;official website&lt;/a&gt;, it is stated that Ruby is, &lt;em&gt;"a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write."&lt;/em&gt; Ruby on Rails on the other hand is a &lt;strong&gt;full stack web development framework&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Packages (programs and libraries) are referred to as &lt;strong&gt;gems&lt;/strong&gt; in Ruby. RubyGems is a package manager for Ruby.Some implementations include GoRuby, Topaz, Opal, mruby and JRuby.&lt;/p&gt;

&lt;p&gt;I would like to share this quote from the creator of the language. He built a language to suit his needs and this was part of it. &lt;/p&gt;

&lt;p&gt;Ruby is a pure object oriented language. &lt;em&gt;Everything is an object.&lt;/em&gt; Even a class is an object.&lt;/p&gt;

&lt;p&gt;Some programming constructs that are supported by Ruby include mixin, open classes, meta programming, duck typing, YAML, automatic returns.&lt;/p&gt;

&lt;p&gt;Features of Ruby lend itself to high quality coding.The redo keyword caught my attention as interesting. Redo, next and retry can be used to control loops.&lt;/p&gt;

&lt;p&gt;Finally, I would like to share this &lt;a href="https://ruby-lang.co/"&gt;useful tutorial&lt;/a&gt; I found&lt;/p&gt;

</description>
      <category>ruby</category>
    </item>
    <item>
      <title>What's vue.js?</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Sun, 10 Jan 2021 12:24:48 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/what-s-vue-js-2oii</link>
      <guid>https://forem.com/bluepaperbirds/what-s-vue-js-2oii</guid>
      <description>&lt;p&gt;&lt;a href="https://vuejs.org/"&gt;Vue.js&lt;/a&gt; it's a JavaScript framework for building front-end UIs. In Vue.JS you can start simple and then progressively add in the tools and features that you need to build a complex web application.  &lt;/p&gt;

&lt;p&gt;At its core it provides a way to build components that encapsulate data or state in your JavaScript and then connect that state reactively to a template in HTML. &lt;/p&gt;

&lt;p&gt;We call these components declarative &lt;strong&gt;views&lt;/strong&gt; because the same data inputs will always produce the same output in the visual UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;p&gt;When we declare data on this data object it links or binds it to the HTML on the template above when the value of the data changes the component will automatically rerender. In other words it's reactive and the framework does a ton of work under the hood to make sure that this process is performance across a huge component tree we can work with this data in the template thanks to views HTML based template syntax we can interpolate a value for expression using double braces and we also have a variety of directives to control the behavior of the HTML based on the data.&lt;/p&gt;

&lt;p&gt;We can use Vue.js to only render an element when the value is True and then we might have a fallback element after that that's only rendered. &lt;/p&gt;

&lt;p&gt;We can do that directly in the template or define a custom method and the components methods object the method has access to our reactive data and that&lt;br&gt;
means all we have to do is change the value of the data and the component will automatically rerender and that's all it takes to build an interactive reactive declarative UI component with Vue.js.&lt;/p&gt;

&lt;p&gt;You can see &lt;a href="https://vuejsexamples.net/"&gt;vue.js examples&lt;/a&gt; here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who uses Vue.js?
&lt;/h2&gt;

&lt;p&gt;The framework is loved by developers for the simplicity but also its ability to scale up in complexity incrementally its plugin system allows you to easily drop in things like a router state management firebase support and more and perhaps&lt;br&gt;
best of all it's not sponsored by some mega corporation. &lt;/p&gt;

&lt;p&gt;It's not pressured to push out new releases all the time and does a great job listening to its community.&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
    <item>
      <title>Start an external program with Python</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Sun, 10 Jan 2021 10:49:43 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/start-an-external-program-with-python-1kf4</link>
      <guid>https://forem.com/bluepaperbirds/start-an-external-program-with-python-1kf4</guid>
      <description>&lt;p&gt;You can start a program using just Python code. You do so by a module called subprocess. &lt;/p&gt;

&lt;p&gt;If it is a terminal program, you can save its output in your Python program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/usr/bin/env python
&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;subprocess&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PIPE&lt;/span&gt;

&lt;span class="n"&gt;process&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;'cat'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'test.py'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;communicate&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;stdout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;cat&lt;/em&gt; command outputs the contents of a file on a Linux system. This may also work on Mac, but if you're on Windows try another command.&lt;/p&gt;

&lt;p&gt;You can start non-terminal programs. This works for any program regardless of if it's something simple like notepad or something more advanced like chrome. &lt;/p&gt;

&lt;p&gt;On Linux there's the program mousepad, which is a clone of the notepad program. You could run it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;subprocess&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;"mousepad"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://pythonspot.com/python-subprocess/"&gt;subprocess&lt;/a&gt; module lets you do all kinds of things with running programs.&lt;/p&gt;

&lt;p&gt;This module is part of the standard modules, so you don't have to install it with the &lt;a href="https://pythonbasics.org/how-to-use-pip-and-pypi/"&gt;Python package manager&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If the program is taking to long to execute, you can use a timeout&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;subprocess&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;executable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"-c"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"import time; time.sleep(3)"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
    </item>
    <item>
      <title>Ruby on OpenBSD</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Sat, 09 Jan 2021 18:10:16 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/ruby-on-openbsd-45j8</link>
      <guid>https://forem.com/bluepaperbirds/ruby-on-openbsd-45j8</guid>
      <description>&lt;p&gt;If you use OpenBSD for security reasons, you can use several versions of &lt;a href="https://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt;. OpenBSD is a unix system that has many built-in security mitigations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Ruby
&lt;/h2&gt;

&lt;p&gt;You can use the command pkg_info to get information on packages&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;doas pkg_info -Q ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This returns all related ruby packages. On the latest OpenBSD version. To check your OpenBSD version&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ uname -a
OpenBSD foo.home 6.8 GENERIC.MP#2 amd64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In my version it returns&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jruby-9.2.13.0
mruby-2.0.1p0
ruby-2.5.8p0
ruby-2.6.6p0
ruby-2.7.1p1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is the default OpenBSD packages, not the ports repository. In the ports repository, they didn't do a security audit on the software packages.&lt;/p&gt;

&lt;p&gt;You can install ruby with the command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;doas pkg_add ruby-2.7.1p1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you are new to Ruby, try this &lt;a href="https://ruby-lang.co/"&gt;Ruby tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then to run program you can use &lt;strong&gt;ruby27&lt;/strong&gt;. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby27 program.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Of course Ruby isn't the only programming language you can use on Go. There's C, C++, &lt;a href="https://golangr.com/"&gt;Golang&lt;/a&gt;, &lt;a href="https://python.org"&gt;Python&lt;/a&gt;, &lt;a href="https://php.net"&gt;PHP&lt;/a&gt; and a lot more.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Interactive websites with vue.js</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Sat, 09 Jan 2021 17:46:35 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/interactive-websites-with-vue-js-57e4</link>
      <guid>https://forem.com/bluepaperbirds/interactive-websites-with-vue-js-57e4</guid>
      <description>&lt;p&gt;JavaScript isn't going anywhere soon, and these days JavaScript is used to make all kinds of things including Web Apps. Who would have thought that the web browser became a kind of operating system?&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Vue.js?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://vuejs.org"&gt;Vue.JS&lt;/a&gt; is javascript framework that inspired by Angular. You can find some &lt;a href="https://vuejsexamples.net/"&gt;Vue examples here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have a single page web page, you can make it interactive using Vue.js.&lt;/p&gt;

&lt;p&gt;You can make all kind of on page interacts with Vue and even small apps that don't require a back-end. In fact one of the things you can do is interact with an API and present the data on a single page (as an app) with Vue.js. &lt;/p&gt;

&lt;p&gt;Pretty cool right? or do you prefer React or another framework when working with the web?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Vue.js?
&lt;/h2&gt;

&lt;p&gt;There are several reasons why you could use vue.js&lt;/p&gt;

&lt;p&gt;First it's approachable. If you already know HTML, CSS and JavaScript you can build things in no time!&lt;/p&gt;

&lt;p&gt;It's scalable and it has a small footprint which is important for page speed. It has a 20KB min+gzip Runtime&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Watermark pdf</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Sat, 09 Jan 2021 16:19:27 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/watermark-pdf-1ap3</link>
      <guid>https://forem.com/bluepaperbirds/watermark-pdf-1ap3</guid>
      <description>&lt;p&gt;You can do a lot of neat things using the Python programming language. Using Python you can easily watermark a pdf. You can use a module called &lt;em&gt;python3-fitz&lt;/em&gt; which uses &lt;a href="https://mupdf.com/"&gt;MuPDF&lt;/a&gt; underneath (install this too)&lt;/p&gt;

&lt;p&gt;If you don't know the Python programming language, I recommend &lt;a href="https://pythonspot.com/"&gt;this tutorial&lt;/a&gt; as a starting point.&lt;/p&gt;

&lt;p&gt;You can install both fitz and mupdf using your package manager.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install python3-fitz
sudo apt install mupdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Python watermark
&lt;/h2&gt;

&lt;p&gt;Then you need an input file and an image. Set the position using the &lt;code&gt;fitz.Rect()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;Load the module like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;fitz&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install it using your operating systems package manager. If you use pip, there seem to be some other packages named fitz which are conflicting.&lt;/p&gt;

&lt;p&gt;Then open the pdf&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;doc = fitz.open("input.pdf")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the location of your watermark&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;rect&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fitz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Rect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Iterate over the pages and insert the water mark&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;page&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insertImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"logo.jpeg"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And save it. The full code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;fitz&lt;/span&gt;
&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fitz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"input.pdf"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;rect&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fitz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Rect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&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;page&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insertImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"logo.jpeg"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"output.pdf"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run the program it will output a new pdf with the watermark image on top of every page.&lt;/p&gt;

&lt;p&gt;Make a backup of your file before you run it. If you want, you can build a GUI around it using something like &lt;a href="https://python-commandments.org/tkinter-basics/"&gt;tkinter&lt;/a&gt; or &lt;a href="https://pythonbasics.org/pyqt-hello-world/"&gt;pyqt&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>try-catch</title>
      <dc:creator>bluepaperbirds</dc:creator>
      <pubDate>Thu, 27 Feb 2020 13:30:39 +0000</pubDate>
      <link>https://forem.com/bluepaperbirds/try-catch-2bg2</link>
      <guid>https://forem.com/bluepaperbirds/try-catch-2bg2</guid>
      <description>&lt;p&gt;Errors can happen if a &lt;a href="https://python.org"&gt;Python&lt;/a&gt; program is running. There are many types of errors, like a "couldn't open file error" or "zero division error".&lt;/p&gt;

&lt;p&gt;If an error pops up, that doesn't mean your program should crash. &lt;/p&gt;

&lt;p&gt;So how do you stop it from crashing?&lt;/p&gt;

&lt;p&gt;You can use the &lt;a href="https://pythonbasics.org/try-except/"&gt;try-except&lt;/a&gt; code. Other programming languages like C# or Java call this the try-catch block.&lt;/p&gt;

&lt;p&gt;You can use this to &lt;em&gt;catch&lt;/em&gt; errors (sounds better than &lt;em&gt;to except&lt;/em&gt;). Some code examples listed below:&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;try&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;5&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="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&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;"Zero division"&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;"End program"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For opening a file, where the filename is given as user input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter file:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Enter&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;         &lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&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="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;"Couldn't open file"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="n"&gt;Couldn&lt;/span&gt;&lt;span class="s"&gt;'t open file
&amp;gt;&amp;gt;&amp;gt; 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Doing some maths, catch different types of exceptions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&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;0&lt;/span&gt;
&lt;span class="k"&gt;try&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;a&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;b&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;'10'&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;TypeError&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;"Cannot add, values are incompatible data types"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ZeroDivisionError&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;"Divided by zero"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can apply this for function calls too, or inside functions.&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;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;accel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;turn&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;"Car error"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



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