<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Skyler Burger</title>
    <description>The latest articles on DEV Community by Skyler Burger (@skybur).</description>
    <link>https://dev.to/skybur</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%2F217242%2Fc7756990-04cb-4423-881f-eab3403b676e.jpg</url>
      <title>DEV Community: Skyler Burger</title>
      <link>https://dev.to/skybur</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/skybur"/>
    <language>en</language>
    <item>
      <title>A Home for LIVE-Screaming Horror</title>
      <dc:creator>Skyler Burger</dc:creator>
      <pubDate>Thu, 08 Oct 2020 19:05:59 +0000</pubDate>
      <link>https://dev.to/skybur/a-home-for-live-screaming-horror-11im</link>
      <guid>https://dev.to/skybur/a-home-for-live-screaming-horror-11im</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--en3eWjPG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kb36dbe7ni9bhrpfu3j3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--en3eWjPG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kb36dbe7ni9bhrpfu3j3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;🎃 Each October my friends and I spend the month indulging in horror movies and pumpkin carving. Though the quarantine has kept everyone physically apart this year, the spirit is still with us. This October I took it upon myself to host a streaming movie marathon for them each week so we can continue to revel in the atmosphere of the season together.&lt;/p&gt;

&lt;p&gt;It crossed my mind to put together a PDF to announce the schedule of screenings but I ultimately decided that this would be a great opportunity to build a simple site my friends could easily check for updates and show times. Though the scope of the site is small and simple, there were still quite a few lessons learned along the way:&lt;/p&gt;

&lt;h2&gt;
  
  
  Sometimes A Library Is Just Clutter
&lt;/h2&gt;

&lt;p&gt;I began building my site with the intention of learning how to use Bootstrap for rapid styling. Once the general layout of the site was completed I realized hardly any of the massive library the browser had been forced to download was being utilized. Here I made the decision to ditch Bootstrap and focus on using CSS3 Flexbox to achieve my responsive design goals without the bloat. Bootstrap, I'll call on you later for a future project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manage Your Media Assets
&lt;/h2&gt;

&lt;p&gt;My site includes a number of film poster images and the required download size grew to well over 8MB which introduced a noticeable delay on page load. Using a free photo editor I was able to reduce the total download size for the entire page to just over 1MB by resizing all of my images. This reduces the amount of data mobile-users have to download and resolved my delayed page load.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Fun Projects
&lt;/h2&gt;

&lt;p&gt;Small, silly projects like this are great practice for those that may be reluctant to touch CSS or front end development. You don't have to jump into a monolithic project to learn something big. What I thought was going to be a one or two hour project turned into multiple days of tweaking wireframes, layouts, assets, and color palettes as I became more determined to make this as polished as possible. Building something that is going to be used by your friends is also a great project motivator!&lt;/p&gt;

&lt;p&gt;Overall, I had a lot of fun building this site and hope this leads to a Live-Screaming Horror Picture Show 2021! Let me know if you have any Halloween favorites I should have included in the schedule, and have a wonderful October! 🎃&lt;/p&gt;

&lt;p&gt;🕸️ Site Link: &lt;a href="https://skylerburger.github.io/lshps/"&gt;https://skylerburger.github.io/lshps/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;1) Don't feel like you have to use a library unless you have good reason to &lt;br&gt;
2) Manage the file sizes for your media assets&lt;br&gt;
3) Build more small, silly projects!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>PVP - A Workflow for Python Projects</title>
      <dc:creator>Skyler Burger</dc:creator>
      <pubDate>Fri, 12 Jun 2020 02:07:16 +0000</pubDate>
      <link>https://dev.to/skybur/pvp-a-workflow-for-python-projects-29h3</link>
      <guid>https://dev.to/skybur/pvp-a-workflow-for-python-projects-29h3</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;I swear I already installed that package twice!!&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Which of these environments belong to my project?!&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Screw it, I'm installing everything globally!!&lt;/strong&gt; 😈&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Managing Python projects can be quite the task, especially if you have more than one on your machine. There are countless workflow approaches to managing your Python versions, environments, and project dependencies. This guide is an overview of one such approach that emphasizes explicit control of your Python versions and virtual environments. The tools we'll be using are Pyenv, Virtualenv, and Poetry, which is why I refer to this as the PVP workflow.&lt;/p&gt;




&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Requirements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Setting Up New Projects&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installing Python Versions&lt;/li&gt;
&lt;li&gt;Creating Virtual Environments&lt;/li&gt;
&lt;li&gt;Installing Project Dependencies&lt;/li&gt;
&lt;li&gt;Git Started&lt;/li&gt;
&lt;li&gt;New Project Summary&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Working with Existing Projects&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting Up Existing Projects&lt;/li&gt;
&lt;li&gt;Managing Project Dependencies&lt;/li&gt;
&lt;li&gt;Removing Virtual Environments&lt;/li&gt;
&lt;li&gt;Removing Python Versions&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Requirements
&lt;/h1&gt;

&lt;p&gt;To follow along with this guide you will need &lt;code&gt;pyenv&lt;/code&gt;, &lt;code&gt;pyenv-virtualenv&lt;/code&gt;, and &lt;code&gt;poetry&lt;/code&gt; installed on your machine. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/pyenv/pyenv/wiki/Common-build-problems"&gt;Pyenv Prerequisites&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Required for &lt;code&gt;pyenv&lt;/code&gt; to build Python interpreters from source.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/pyenv/pyenv-installer"&gt;Pyenv Installer&lt;/a&gt;&lt;/strong&gt; (Recommended approach)&lt;/p&gt;

&lt;p&gt;Will install &lt;code&gt;pyenv&lt;/code&gt; as well as &lt;code&gt;pyenv-virtualenv&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://python-poetry.org/docs/#installation"&gt;Poetry Installation Page&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Be sure to check out everything &lt;code&gt;poetry&lt;/code&gt; can do by skimming the docs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you are a Windows user utilizing Windows Subsystem for Linux, be sure that you are installing these tools on the subsystem rather than Windows.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Setting Up New Projects
&lt;/h1&gt;

&lt;p&gt;This section of the guide focuses on quickly setting up a brand new Python project. Here we'll be ensuring we have the version of Python we want to use, creating a virtual environment for our project to play in, and installing project dependencies inside that environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Installing Python Versions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating Virtual Environments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Installing Project Dependencies&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Git Started&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;New Project Summary&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Installing Python Versions
&lt;/h2&gt;

&lt;p&gt;Before creating a virtual environment and installing your project dependencies, we should make sure that the Python version you'd like to utilize is installed on your machine. We'll use Pyenv to install and manage different versions of Python. The following commands can be executed from any location on your file system.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check the versions of Python currently available on your machine.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;versions&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This will show you a list of each version of Python that Pyenv has installed on your machine. If the version you want is listed you can skip down to the next section of this guide on Creating Virtual Environments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check the versions of Python that Pyenv is able to install on your machine.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This command will list out all of the versions of Python that are available for installation. The version you want is most likely one of the simple semantic versioning numbers at the very top of the list (such as 3.8.2).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install your desired version of Python on your machine.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template:
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example:
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="mf"&gt;3.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="c1"&gt;# Verbose Example
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="mf"&gt;3.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This process can take about 5 mins so sit tight while it's working. If you want visual feedback on the installation process, add the optional &lt;code&gt;-v&lt;/code&gt; flag for a verbose printout of the actions Pyenv is taking during installation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify that the desired version was installed.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;versions&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This will list out all of the version of Python that Pyenv has installed on your machine. We should now see the version you just installed on the list.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Creating Virtual Environments
&lt;/h2&gt;

&lt;p&gt;Now that we have our desired version of Python installed on our machine, let's use Virtualenv to create a virtual environment for our project to use. This virtual environment is like a playground containing your desired version of Python and any packages that you install for your project. Within this playground your project can play with reduced fear of interfering with other Python projects on your machine. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a directory for your project and move into it.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;mdkir&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sweet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sweet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a virtual environment for your project and give it a name that matches your project.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt; &lt;span class="mf"&gt;3.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sweet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Using this naming convention makes it easy to select the virtual environment containing your dependencies in IDEs like VS Code or Jupyter Lab since the virtual environment's name matches your project's name.&lt;/p&gt;

&lt;p&gt;If you check &lt;code&gt;pyenv versions&lt;/code&gt; after this step you will now see your new virtual environment is listed as an available version of Python.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Set your new virtual environment as the local version of Python.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;local&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;virtual_environment_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;local&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sweet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This command will ask Pyenv to create a &lt;code&gt;.python-version&lt;/code&gt; file in the current directory. This file tells Pyenv that any time we are in this directory, the version of Python we want to use is located in our virtual environment. Now anytime we navigate to this directory, Pyenv quietly switches the Python version to the virtual environment automatically. Whenever we leave this directory, Pyenv will switch the Python version back to the system default, unless it encounters another &lt;code&gt;.python-version&lt;/code&gt; file that specifies which version to use instead.&lt;/p&gt;

&lt;p&gt;You can double-check &lt;code&gt;python -V&lt;/code&gt; at this point to verify that the version of Python that is currently recognized matches the version you used to create the virtual environment.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Installing Project Dependencies
&lt;/h2&gt;

&lt;p&gt;Now that we have a virtual environment utilizing our desired version of Python, we can start managing our new project's dependencies with Poetry.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Initialize your project.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;

&lt;span class="c1"&gt;# Alternatively, if you want to skip the prompts use:
&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Poetry will create a &lt;code&gt;pyproject.toml&lt;/code&gt; file that is used to keep track of some basic project information as well as any dependencies you install for the project.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install project dependencies.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="n"&gt;jupyterlab&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;When Poetry installs these packages, it places them within the virtual environment that was set as the local version of Python. Poetry will also add the name of the package to your project's &lt;code&gt;.pyproject.toml&lt;/code&gt; file as a dependency. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Activate Poetry's shell.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;To use the dependencies that Poetry has installed, we need to activate Poetry's shell before executing our code. &lt;/p&gt;

&lt;p&gt;Sometimes it can be unclear whether the shell is active or not. To verify if Poetry's shell is active you can check your environment variables with the following command, &lt;code&gt;echo $POETRY_ACTIVE&lt;/code&gt;. If the Poetry shell is active it will return a &lt;code&gt;1&lt;/code&gt;, otherwise it will print a blank line to your terminal.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Git Started
&lt;/h2&gt;

&lt;p&gt;Now that your project is all set up, you probably want to keep track of your work with a version control system. Here we'll be connecting our project to GitHub for safekeeping.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigate to the root directory of your project.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a few required files.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;touch&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gitignore&lt;/span&gt; &lt;span class="n"&gt;README&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;md&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;At minimum, your &lt;code&gt;README.md&lt;/code&gt; should have a top-level header with your project's name so it is rendered on your GitHub repository's page.&lt;/p&gt;

&lt;p&gt;Be sure to fill in your &lt;code&gt;.gitignore&lt;/code&gt; file with the appropriate file names, file extensions, and directories to be ignored. &lt;a href="http://gitignore.io/"&gt;GitIgnore.io&lt;/a&gt; is a great &lt;code&gt;.gitignore&lt;/code&gt; generator.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Initialize your project as a Git repository.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create your first commit.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;commit_message&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a new, empty GitHub repository online.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in to &lt;a href="https://www.github.com/"&gt;GitHub&lt;/a&gt; and create a new repository. DO NOT create the repo with a license, &lt;code&gt;README.md&lt;/code&gt;, or &lt;code&gt;.gitignore&lt;/code&gt; file. Once the repo has been created you'll see a page with a bunch of commands you can copy/paste into your terminal to finish setting up the repo. We'll use these in the next step.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create an upstream remote and push your work to GitHub.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To complete the set up we'll want the two commands listed on your GitHub repository's page under &lt;em&gt;"... or push an existing repository from the command line"&lt;/em&gt;. You can copy/paste those commands directly into your terminal or type them out if you can spot the HTTPS link to your repo (it ends in .git).&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;remote&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;link_from_github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;push&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt; &lt;span class="n"&gt;master&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;After this you're ready to proceed with your usual Git flow.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  New Project Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create Project Directory&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create Virtual Environment&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;local&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;virtual_environment_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install Dependencies&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;
&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Activate Poetry's Shell&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;

&lt;span class="c1"&gt;# (optional) Check if the shell is active
&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;POETRY_ACTIVE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Git Started&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Add your README.md and .gitignore files, then
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;commit_message&amp;gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Create new, empty repo on GitHub, then
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;remote&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;link_from_github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;push&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt; &lt;span class="n"&gt;master&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Working with Existing Projects
&lt;/h1&gt;

&lt;p&gt;This section of the guide will focus on how to use the PVP workflow with existing projects. We'll start from the very beginning and assume you are cloning a repository from GitHub on your machine and then move forward from there.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Setting Up Existing Projects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Managing Project Dependencies&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Removing Virtual Environments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Removing Python Versions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Setting Up Existing Projects
&lt;/h2&gt;

&lt;p&gt;This setup process assumes that you are cloning a repository that utilized Poetry for dependency management. Mainly we want to make sure that the repository has a &lt;code&gt;pyproject.toml&lt;/code&gt; and &lt;code&gt;poetry.lock&lt;/code&gt; file which are used to notify Poetry which packages (and more specifically which versions) are required as dependencies for the project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Clone the repository from GitHub to your macine.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;clone&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;link_from_github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check the required version of Python.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;repository_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;cat&lt;/span&gt; &lt;span class="n"&gt;pyproject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;toml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;The &lt;code&gt;cat&lt;/code&gt; command will print out the contents of the &lt;code&gt;pyproject.toml&lt;/code&gt; file. Under &lt;code&gt;[tool.poetry.dependencies]&lt;/code&gt; you'll see a specification for which versions of Python will work with the project. The example below indicates that the project requires a version of Python that is 3.8 or higher.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Partial example of cat output
&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;tool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"^3.8"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check that you have the right version of Python installed.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;versions&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Use this command to see which versions of Python are available on your system. If you see a version that meets the project requirements you can move on to the next step.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you do not see a version of Python that meets the project requirements, please follow the Installing Python Versions section to identify and install a version that is compatible with the project.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a virtual environment for the project.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt; &lt;span class="mf"&gt;3.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sweet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Set your virtual environment as the local Python version.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;local&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;virtual_environment_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;local&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sweet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install the project's dependencies.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Poetry will now read through your &lt;code&gt;pyproject.toml&lt;/code&gt; to see which dependencies are required by the project. If the project includes a &lt;code&gt;poetry.lock&lt;/code&gt;, Poetry will also examine that file to see which versions of each dependency are required. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Shell up and get to work!&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Managing Project Dependencies
&lt;/h2&gt;

&lt;p&gt;Here are a few basic Poetry commands that will help you install, remove, and inspect dependencies for your projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Project Dependencies
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Adding a single package
&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Adding multiple packages
&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Removing Project Dependencies
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Remove a single package
&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;remove&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Remove multiple packages
&lt;/span&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;remove&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;package_name_2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Listing Installed Dependencies
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;poetry&lt;/span&gt; &lt;span class="n"&gt;show&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h2&gt;
  
  
  Removing Virtual Environments
&lt;/h2&gt;

&lt;p&gt;When you are no longer examining or working on a project, you may want to perform a little clean up on your machine. Getting rid of the project is as simple as deleting the directory containing the project. It's only one additional step to remove the virtual environment and accompanying installed packages from your machine as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;virtual_environment_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;virtualenv&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sweet&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;You will be prompted to confirm that you want to delete your virtual environment by entering &lt;code&gt;'y'&lt;/code&gt; on the terminal.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Removing Python Versions
&lt;/h2&gt;

&lt;p&gt;Have you installed an experimental build or moved on to the new best thing? At some point you'll probably want to remove a version of Python from your system. Pyenv brought Python into our machine, and so help us, it will take it out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Template
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;uninstall&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;pyenv&lt;/span&gt; &lt;span class="n"&gt;uninstall&lt;/span&gt; &lt;span class="mf"&gt;3.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This is simply one approach out of many towards managing all of the moving pieces associated with development on a Python project. Use aspects that you like, plug in tools that you prefer, and make it your own! There is no one correct answer and I would love to hear about workflows that others are using.&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>.get() More with Less from Python Dictionaries</title>
      <dc:creator>Skyler Burger</dc:creator>
      <pubDate>Thu, 21 Nov 2019 21:26:21 +0000</pubDate>
      <link>https://dev.to/skybur/get-more-with-less-from-python-dictionaries-1j0p</link>
      <guid>https://dev.to/skybur/get-more-with-less-from-python-dictionaries-1j0p</guid>
      <description>&lt;p&gt;I recently started volunteering to help host a few interview practice nights for Seattle's local Python user group, &lt;a href="https://www.pspython.com/app/"&gt;PuPPy (Puget Sound Programming Python)&lt;/a&gt;, and have seen some amazing people coming together to solve whiteboarding problems in the dead of night. During these practice nights I've been delighted by the opportunities I've had to share one of my absolute favorite Python tricks and today I'd like to share it with you.&lt;/p&gt;

&lt;p&gt;Have you been in a situation where you needed to store the frequency of keys within a dictionary and have written something similar to this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example 1
&lt;/span&gt;
&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Hello World!'&lt;/span&gt;
&lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&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;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="c1"&gt;# Equivalent to counts[char] = counts[char] + 1
&lt;/span&gt;    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;KeyError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I don't particularly care for the look of that try/except block. &lt;/p&gt;

&lt;p&gt;The problem here is that dictionaries do not have a default return value when a program uses bracket notation to access a key that is not already present within the dictionary. Instead Python handily crashes the program with a &lt;code&gt;KeyError&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;In the case above, if the code in the &lt;code&gt;try&lt;/code&gt; clause throws a &lt;code&gt;KeyError&lt;/code&gt; we know that the key is not present in the dictionary. The program then enters the &lt;code&gt;except&lt;/code&gt; clause where we add the key to the dictionary by explicitly assigning it a value of 1. The next time that key is encountered the &lt;code&gt;try&lt;/code&gt; clause will not throw an error and the key's value will be incremented by 1.&lt;/p&gt;

&lt;p&gt;What if there was a better way, something sleeker, something that doesn't call out that you may be knowingly throwing errors within your code? &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/j5ElOMw40c0H6uvBtf/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/j5ElOMw40c0H6uvBtf/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well it turns out there is a method within dictionaries that does just that, &lt;code&gt;.get()&lt;/code&gt;. Calling &lt;code&gt;.get()&lt;/code&gt; on a dictionary while passing in the desired key will return the value associated with that key, or &lt;code&gt;None&lt;/code&gt; if the key is not present. This method allows us to modify Example 1 into something a little less hacky in appearance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example 2
&lt;/span&gt;
&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Hello World!'&lt;/span&gt;
&lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&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;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That just feels better to look at, right? No errors on this horizon!&lt;/p&gt;

&lt;p&gt;Now if the dictionary doesn't contain the key, the default &lt;code&gt;None&lt;/code&gt; is returned. Since &lt;code&gt;None&lt;/code&gt; is considered &lt;a href="https://docs.python.org/3/library/stdtypes.html#truth-value-testing"&gt;falsey&lt;/a&gt;, the code within the &lt;code&gt;if&lt;/code&gt; clause is not executed and we move into the &lt;code&gt;else&lt;/code&gt; clause to assign the initial value for the given key. &lt;/p&gt;

&lt;p&gt;Be careful when using &lt;code&gt;.get()&lt;/code&gt; in logic though, if the value associated with the key is 0, that is also considered falsey and the code within the &lt;code&gt;if&lt;/code&gt; clause would not execute. It wouldn't make a difference with this specific example but it could in other scenarios. In those cases I would suggest something along the lines of &lt;code&gt;if counts.get(char) != None:&lt;/code&gt; to check if the value associated with the key is anything other than &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;🤔 Hmm, but Example 2 doesn't seem to have any less lines of code than Example 1. Well, there's more goodness stashed away in &lt;code&gt;.get()&lt;/code&gt;. This method also accepts an optional second argument that defines the default return value. Not satisfied with &lt;code&gt;None&lt;/code&gt;? Then let's do something about it!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example 3
&lt;/span&gt;
&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Hello World!'&lt;/span&gt;
&lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&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;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;char&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="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://i.giphy.com/media/11jIcdl19gWkAE/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/11jIcdl19gWkAE/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's... beautiful! &lt;/p&gt;

&lt;p&gt;A lot is happening on that last line. The &lt;code&gt;.get()&lt;/code&gt; method checks the dictionary for the given key and returns either the value associated with the key or the default return value we specified as the second argument, 0. We add 1 to whatever is returned from &lt;code&gt;.get()&lt;/code&gt;, assign the sum as the value for the key, and call it a day.&lt;/p&gt;

&lt;p&gt;The examples above have dealt with a simple counting scenario but &lt;code&gt;.get()&lt;/code&gt; can be used practically anywhere you're checking keys in a dictionary. If you're specifically in the counting business, I'd recommend you that you also take a peek at the incredible &lt;a href="https://docs.python.org/3.7/library/collections.html#collections.Counter"&gt;&lt;code&gt;Counter&lt;/code&gt;&lt;/a&gt; class from the Python Standard Library's &lt;code&gt;collections&lt;/code&gt; module.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example 4
&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;

&lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Counter&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;Thank you for reading my love letter to &lt;code&gt;.get()&lt;/code&gt;! Let me know how you've used &lt;code&gt;.get()&lt;/code&gt; or if you know a Python trick that you feel everyone should be embracing.&lt;/p&gt;

&lt;p&gt;👋&lt;/p&gt;

</description>
      <category>python</category>
      <category>dict</category>
      <category>dictionary</category>
    </item>
  </channel>
</rss>
