<?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: icncsx</title>
    <description>The latest articles on Forem by icncsx (@icncsx).</description>
    <link>https://forem.com/icncsx</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%2F370719%2F5d728611-b3b9-4470-aff3-ce5c0f65c24f.png</url>
      <title>Forem: icncsx</title>
      <link>https://forem.com/icncsx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/icncsx"/>
    <language>en</language>
    <item>
      <title>Parameter usage for default args in JS</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Wed, 24 Nov 2021 20:59:57 +0000</pubDate>
      <link>https://forem.com/icncsx/parameter-usage-for-default-args-in-js-4b0g</link>
      <guid>https://forem.com/icncsx/parameter-usage-for-default-args-in-js-4b0g</guid>
      <description>&lt;p&gt;A default argument can reference a prior argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;defaultFunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;num2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;num1&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="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="s2"&gt;`num1: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; num2: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;defaultFunc&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="c1"&gt;// num1: 3 num2: 3&lt;/span&gt;
&lt;span class="nx"&gt;defaultFunc&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="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// num1: 3 num2: 6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>shorts</category>
    </item>
    <item>
      <title>Boolean coercion</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Wed, 24 Nov 2021 20:53:57 +0000</pubDate>
      <link>https://forem.com/icncsx/boolean-coercion-2ckc</link>
      <guid>https://forem.com/icncsx/boolean-coercion-2ckc</guid>
      <description>&lt;p&gt;Use !! to see how JavaScript would coerce a real value into a boolean-ish interpretation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&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="o"&gt;!!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&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="o"&gt;!!&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;//  false&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="o"&gt;!!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//  true&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="o"&gt;!!&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//  false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>shorts</category>
    </item>
    <item>
      <title>Assignment has a return value in JS</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Wed, 24 Nov 2021 20:47:33 +0000</pubDate>
      <link>https://forem.com/icncsx/assignment-has-a-return-value-in-js-2359</link>
      <guid>https://forem.com/icncsx/assignment-has-a-return-value-in-js-2359</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&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;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="c1"&gt;// 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because assignment has a return value, we are able to chain assignments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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="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;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&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;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hard to read, but it works...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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="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;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3&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;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Difference between parameter and argument</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Wed, 17 Nov 2021 17:21:37 +0000</pubDate>
      <link>https://forem.com/icncsx/difference-between-parameter-and-argument-50p0</link>
      <guid>https://forem.com/icncsx/difference-between-parameter-and-argument-50p0</guid>
      <description>&lt;p&gt;The two terms are used interchangeably in conversation, but they mean different things. You pass arguments when calling a method. And you use parameters within the method body.&lt;/p&gt;

&lt;p&gt;As most if not all programming languages are copy-by-value, the two are equivalent, only differing in the context. The two terms exist to distinguish whether you are talking about a method definition or a method call. When you're calling a method, you pass in arguments. When you're actually in the method body, you are using parameters. Arguments get copied-by-value to parameters.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>computerscience</category>
      <category>shorts</category>
    </item>
    <item>
      <title>Uploading Docker Images to AWS ECR</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Sun, 14 Nov 2021 19:38:55 +0000</pubDate>
      <link>https://forem.com/icncsx/uploading-docker-images-to-aws-ecr-dgp</link>
      <guid>https://forem.com/icncsx/uploading-docker-images-to-aws-ecr-dgp</guid>
      <description>&lt;h2&gt;
  
  
  AWS
&lt;/h2&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Create an ECR Repo&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ecr create-repository &lt;span class="nt"&gt;--repository-name&lt;/span&gt; &amp;lt;name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;code&gt;Log-in to ECR&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ecr get-login-password &lt;span class="nt"&gt;--region&lt;/span&gt; region | docker login &lt;span class="nt"&gt;--username&lt;/span&gt; AWS &lt;span class="nt"&gt;--password-stdin&lt;/span&gt; &amp;lt;registry_id&amp;gt;.dkr.ecr.&amp;lt;region&amp;gt;.amazonaws.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;code&gt;Tag your image&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Tag your image with the Amazon ECR registry, repository, and optional image tag name combination to use. This is important if we want to push to ECR and not DockerHub.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker tag &amp;lt;image_id&amp;gt; &amp;lt;registry_id&amp;gt;.dkr.ecr.region.amazonaws.com/&amp;lt;repo_name&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;code&gt;Upload image to ECR&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker push &amp;lt;registryId&amp;gt;.dkr.ecr.&amp;lt;region&amp;gt;.amazonaws.com/&amp;lt;repo&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>aws</category>
      <category>cloud</category>
      <category>cloudskills</category>
      <category>programming</category>
    </item>
    <item>
      <title>Lambda container approach in AWS</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Sun, 14 Nov 2021 19:28:24 +0000</pubDate>
      <link>https://forem.com/icncsx/lambda-container-approach-in-aws-23p4</link>
      <guid>https://forem.com/icncsx/lambda-container-approach-in-aws-23p4</guid>
      <description>&lt;h2&gt;
  
  
  &lt;code&gt;Zip vs Container Approach&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;There are two ways to use Lambda functions in AWS. One is to provide the deployable artifact in the form of a zip file. You then have a variety of runtimes you can choose from: &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html"&gt;https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The other approach is the Lambda container approach. IMO, the container approach to Lambda management has two main advantages over the zip approach. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Runtime selection&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;With the zip approach, you have to rely on Amazon supporting the desired runtime. For example, if your code depends on Python3.10, you better hope that Amazon supports that. In a container approach however, the runtime is something you have full control over. Just make sure either your base image supports the runtime or you install the runtime as part of one of your RUN statements.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Building dependencies&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Non-native packages such as pandas, lxml, etc have to be built in the target environment for the compiled binaries to work. For example, if you build pandas on Mac, then the compiled binaries will work on Mac - not on Amazon Linux 2 which is what Lambda runs on.&lt;/p&gt;

&lt;p&gt;With containers, you no longer have to worry about building for a target OS, as you're able to encapsulate OS details in an image. Put simply, the image you build locally will just work in Lambda. How easy is that!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>programming</category>
      <category>devops</category>
    </item>
    <item>
      <title>What is manylinux?</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Thu, 11 Nov 2021 21:09:40 +0000</pubDate>
      <link>https://forem.com/icncsx/what-is-manylinux-4ojd</link>
      <guid>https://forem.com/icncsx/what-is-manylinux-4ojd</guid>
      <description>&lt;h2&gt;
  
  
  &lt;code&gt;Why Python packaging can be hard&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;There may be a time in your development career where you need to author a package that extends Python w/ C or C++. In such a case your Python package needs to go through a compilation process, which converts C or C++ to binaries that work for a specific target system. This becomes really tedious when you think about how many flavors and versions of Linux there are.  Building a separate binary for Red Hat, SUSE, Ubuntu, etc... Ugh so tiring.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Why Python packaging can be easy w/ manylinux&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Fortunately, there is a solution. &lt;code&gt;manylinux&lt;/code&gt; was birthed to make it easy for your Python packages to be compatible with most Linux variants. &lt;code&gt;manylinux&lt;/code&gt; takes advantage of the fact that most distributions are mindful of backwards compatibility, and intentionally builds bdist wheels on an old version of a distribution. The idea is that if we build on an old supported version, the binaries produced are compatible with current versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;So what is a manylinux really? Is it a ham sandwich?&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;No. Even better. It's a Docker image. &lt;code&gt;manylinux&lt;/code&gt; is a &lt;code&gt;Docker&lt;/code&gt; image built off a certain old versions of the CentOS operating system that comes bundled with libraries that are assumed to be present by default on almost all Linux systems.&lt;/p&gt;

&lt;p&gt;You can find an example of manylinux distributions within the pandas project. Here are two (out of many) from the list of available pandas downloads from PyPI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pandas-1.0.3-cp37-cp37m-manylinux1_x86_64.whl
pandas-1.0.3-cp37-cp37m-manylinux1_i686.whl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, pandas has built manylinux wheels for CPython 3.7 supporting both x86-64 and i686 architectures. It's manylinux so this wheel should be compatible for many linux :)&lt;/p&gt;

&lt;p&gt;Happy packaging!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>todayilearned</category>
      <category>programming</category>
      <category>linux</category>
    </item>
    <item>
      <title>Python Packaging: sdist vs bdist</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Thu, 11 Nov 2021 20:54:55 +0000</pubDate>
      <link>https://forem.com/icncsx/python-packaging-sdist-vs-bdist-5ekb</link>
      <guid>https://forem.com/icncsx/python-packaging-sdist-vs-bdist-5ekb</guid>
      <description>&lt;h2&gt;
  
  
  &lt;code&gt;Why packages?&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Let's start with a fundamental question: why package at all? Reason is fairly simple. Once you have created a package, then you are likely to use some of the code in other places. For example, you might want to do 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;from&lt;/span&gt; &lt;span class="nn"&gt;mypkg.module&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;func&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;What is a distribution?&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A Python distribution is a versioned compressed archive file that contains your Python package. The distribution file is what an end-user (the client) will download from the internet when they run &lt;code&gt;pip install&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are two primary distribution types in use today: &lt;code&gt;Built Distributions&lt;/code&gt; and &lt;code&gt;Source Distributions&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Source Distribution (sdist)&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A source distributions is the simpler of the two types of distributions. Intuitively speaking, an &lt;code&gt;sdist&lt;/code&gt; is very similar to source code - the code that you write. Therefore, &lt;code&gt;sdist&lt;/code&gt; will not include platform-specific binaries. The result is an archive (.tar.gz) that contains the source code of your package and instructions on how to build it, and the target system of your client will perform the actual build to create a bdist (wheel).&lt;/p&gt;

&lt;p&gt;Creating an sdist is akin to sharing just the source. It doesn't build usable artifacts that the client can consume immediately. The advantage of this is that creating an sdist is the same for all platforms (Windows, Linux, Mac) and machines (32 Bit / 64 Bit). The disadvantage is that users have to build the package themselves once they download the sdist.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Built Distribution (bdist)&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A built distribution, also sometimes referred to as a &lt;code&gt;bdist&lt;/code&gt;, is more complex than an sdist in that it actually "builds" the package. Principally, &lt;code&gt;bdist&lt;/code&gt; creates a distribution containing &lt;code&gt;.so&lt;/code&gt;, &lt;code&gt;.dll&lt;/code&gt;, &lt;code&gt;.dylib&lt;/code&gt; for binary modules. The result is an archive that is specific to a platform (for example linux-x86_64) and to a version of Python (for example Python3.9). &lt;/p&gt;

&lt;p&gt;Installing a &lt;code&gt;bdist&lt;/code&gt; in the client is immediate, as they don't need to build anything (you as the package author have already built it for them, setuptools doesn't need to build it). The downside is that you as the package author have to build for multiple platforms and versions and upload all of the distributions for max compatibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Should I produce sdist or bdist for clients?&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;It is best practice to upload both, wheels and a source distribution, because any built distribution format only works for a subset of target systems. If there is not a platform-specific bidst that works for the end-user, they can go ahead and build locally w/ the &lt;code&gt;sdist&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>todayilearned</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>pip stuff you might need to know</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Thu, 11 Nov 2021 19:51:36 +0000</pubDate>
      <link>https://forem.com/icncsx/pip-stuff-you-might-need-to-know-2jjb</link>
      <guid>https://forem.com/icncsx/pip-stuff-you-might-need-to-know-2jjb</guid>
      <description>&lt;h2&gt;
  
  
  &lt;code&gt;PIP&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;pip is the standard package manager for Python. It allows you to install and manage additional packages that are not part of the Python standard library. The concept of a package manager might be familiar to you if you are coming from other languages. For example, JavaScript uses &lt;code&gt;npm&lt;/code&gt; for package management.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;pip3 vs pip&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;pip is also the CLI command that you will use to interact with pip, and there are many variants.&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; pip install pandas
&amp;gt; pip2 install pandas
&amp;gt; pip3 install pandas
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The thing to note here is that &lt;code&gt;pip3&lt;/code&gt; operates on a &lt;code&gt;Python3&lt;/code&gt; environment only, as &lt;code&gt;pip2&lt;/code&gt; does with &lt;code&gt;Python2&lt;/code&gt;. &lt;code&gt;pip&lt;/code&gt; (w/o the 2 or 3) operates contextually. For example, if you are in a &lt;code&gt;Python3&lt;/code&gt; virtual environment, &lt;code&gt;pip&lt;/code&gt; will operate on the &lt;code&gt;Python3&lt;/code&gt; environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;But pip3 can mean many things - like if I have Python3.7 and Python3.8?&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Yes that's correct. Let's say I have two versions of Python installed, like Python 3.7 and 3.8. Now, if you were to type pip or pip3 in your terminal, it's not very clear which Python interpreter gets involved.&lt;/p&gt;

&lt;p&gt;And this is why you'll see many developers use &lt;code&gt;python -m pip&lt;/code&gt;. &lt;code&gt;python -m pip&lt;/code&gt; executes pip using the Python interpreter you specified as &lt;code&gt;python&lt;/code&gt;. Here you can provide the full path to the interpreter like: &lt;code&gt;/usr/bin/python3.7 -m pip&lt;/code&gt; instead of relying on an alias.&lt;/p&gt;

</description>
      <category>python</category>
      <category>todayilearned</category>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Program vs Process vs Thread</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Thu, 11 Nov 2021 18:59:25 +0000</pubDate>
      <link>https://forem.com/icncsx/program-vs-process-vs-thread-51bm</link>
      <guid>https://forem.com/icncsx/program-vs-process-vs-thread-51bm</guid>
      <description>&lt;h2&gt;
  
  
  &lt;code&gt;Program&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A program is simply an executable file that contains a set of instructions to complete a task. An application such as Chrome is one example.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Process&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A process is any currently running instance of a program. So one program can have several executions (copies) of it running at once. One Chrome program can have multiple tabs/windows open. A colleague compares the relationship between a program and process to the difference between a Docker image and a container; I hope that analogy makes sense :)&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Thread&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;One process can have multiple running threads. Put simply, a thread does lightweight, singular jobs. Threads exist for added concurrency. A process can have many jobs: think saving a file, reading keyboard input, writing logs, etc. Each thread can be responsible for its own task or "subprocess" so to speak.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>codenewbie</category>
      <category>computerscience</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Functions are first class objects</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Wed, 06 Jan 2021 08:29:08 +0000</pubDate>
      <link>https://forem.com/icncsx/functions-are-first-class-objects-1dmb</link>
      <guid>https://forem.com/icncsx/functions-are-first-class-objects-1dmb</guid>
      <description>&lt;p&gt;By functions being first-class objects, we mean that we can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;assign functions to variables&lt;/li&gt;
&lt;li&gt;store functions in data structures&lt;/li&gt;
&lt;li&gt;pass functions as arguments to other functions&lt;/li&gt;
&lt;li&gt;return functions as values from other functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Assignment&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-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;yell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'!'&lt;/span&gt;

&lt;span class="n"&gt;bark&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;yell&lt;/span&gt;
&lt;span class="n"&gt;bark&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'woof'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;Functions can be stored in data structures&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;funcs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;capitalize&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;f&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;funcs&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;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'hey there'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;Functions can be passed to other functions&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-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;yell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'!'&lt;/span&gt;

&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yell&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'hello'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'hey'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'hi'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;Functions can be returned from other functions&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-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;talk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;volume&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;whisper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'...'&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;yell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'!'&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;yell&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;return&lt;/span&gt; &lt;span class="n"&gt;whisper&lt;/span&gt;

&lt;span class="n"&gt;talk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="s"&gt;"hello"&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>todayilearned</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>What determines the truthiness of an object in Python?</title>
      <dc:creator>icncsx</dc:creator>
      <pubDate>Fri, 25 Dec 2020 23:01:20 +0000</pubDate>
      <link>https://forem.com/icncsx/what-determines-the-truthiness-of-an-object-in-python-2e99</link>
      <guid>https://forem.com/icncsx/what-determines-the-truthiness-of-an-object-in-python-2e99</guid>
      <description>&lt;p&gt;In Python we have truthy and falsy values. For example 0 is falsy and all other numbers are truthy. In fact, all objects in Python have a truth value. &lt;/p&gt;

&lt;p&gt;By default, all objects are considered to be truthy.&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;class&lt;/span&gt; &lt;span class="nc"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;# True
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to override this default behaviour, you have to implement the &lt;code&gt;__bool__&lt;/code&gt; method. If an object defines &lt;code&gt;__bool__&lt;/code&gt;, then Python calls that method to determine its truthiness.&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;class&lt;/span&gt; &lt;span class="nc"&gt;Bar&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;__bool__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

&lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bar&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;# False
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now all instances of Bar are False.&lt;/p&gt;

</description>
      <category>python</category>
      <category>todayilearned</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
