<?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: HackerCulture</title>
    <description>The latest articles on DEV Community by HackerCulture (@hackerculture).</description>
    <link>https://dev.to/hackerculture</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%2F950572%2F7446b568-4d18-45e1-9492-924ba538066b.png</url>
      <title>DEV Community: HackerCulture</title>
      <link>https://dev.to/hackerculture</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hackerculture"/>
    <language>en</language>
    <item>
      <title>The Ultimate Python Programmer Roadmap (2023)</title>
      <dc:creator>HackerCulture</dc:creator>
      <pubDate>Tue, 10 Jan 2023 21:42:31 +0000</pubDate>
      <link>https://dev.to/hackerculture/the-ultimate-python-programmer-roadmap-2023-2ghb</link>
      <guid>https://dev.to/hackerculture/the-ultimate-python-programmer-roadmap-2023-2ghb</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gaPvuykx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.hackerculture.com/content/images/size/w2000/2023/01/A-follow-up-to-the-unfortunate-thread-from-the-weekend-As--1-.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gaPvuykx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.hackerculture.com/content/images/size/w2000/2023/01/A-follow-up-to-the-unfortunate-thread-from-the-weekend-As--1-.jpg" alt="The Ultimate Python Programmer Roadmap (2023)" width="880" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At &lt;strong&gt;HackerCulture&lt;/strong&gt; , we're all about Python. Our mission is to get more people familiar with the Python programming language, and we teach you how to use python to write better programs.&lt;/p&gt;

&lt;p&gt;Python is the most loved programming language by both beginners and experts, according to multiple surveys. And not only software developers but other people from different disciplines use Python for a variety of different tasks, such as data analysis and visualization, artificial intelligence and machine learning, automation, etc.&lt;/p&gt;

&lt;p&gt;There has never been a better time to learn Python, and with our resources created by professional Python developers with decades of experience, you can learn the skills and techniques that really matter in the real world. You can use Python to build web apps, mobile apps, and desktop applications, as well as software testing and even some actual hacking.&lt;/p&gt;

&lt;p&gt;Whether your goal is to learn python for web development, data science, or machine learning, we'll go over the most important libraries and resources to learn after getting the basics down.&lt;/p&gt;

&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python Basics&lt;/li&gt;
&lt;li&gt;Intermediate Python&lt;/li&gt;
&lt;li&gt;Advanced Python Topics&lt;/li&gt;
&lt;li&gt;Python for Web Development&lt;/li&gt;
&lt;li&gt;Python for Automation&lt;/li&gt;
&lt;li&gt;Python for DevOps&lt;/li&gt;
&lt;li&gt;Python for Data Science&lt;/li&gt;
&lt;li&gt;Python for Machine Learning&lt;/li&gt;
&lt;li&gt;Tips for learning Python programming&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Python Basics
&lt;/h2&gt;

&lt;p&gt;First, we need to install python so we can play around with it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.hackerculture.com/python-setup/"&gt;Setting Up Python and Virtualenvs with Pyenv&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, you can follow this roadmap to go from Python beginner to knowing &lt;em&gt;"just enough to be dangerous"&lt;/em&gt; with Python. While this list doesn't cover every single feature, it does cover many of Python’s most noteworthy features and will enable you to read and write Python modules and programs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://realpython.com/courses/python-basics-first-program/"&gt;Python Basics: Code Your First Python Program&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Variables and operators&lt;/li&gt;
&lt;li&gt;Numbers and math&lt;/li&gt;
&lt;li&gt;Strings and string methods&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hackerculture.com/basic-python-data-types/"&gt;Basic Data Types in Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Loops in Python&lt;/li&gt;
&lt;li&gt;Exception handling&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/courses/defining-and-calling-functions/"&gt;Functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Modules&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Intermediate Python
&lt;/h2&gt;

&lt;p&gt;This section will give you the tools to make complex applications and introduce you to concepts about Object Oriented Programming (OOP) in Python:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://realpython.com/courses/intro-object-oriented-programming-oop-python/"&gt;Classes and Objects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/courses/python-basics-file-system-operations/"&gt;File System Operations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/courses/python-basics-dictionaries/"&gt;Dictionaries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/courses/using-list-comprehensions-effectively/"&gt;Lists and List Comprehensions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/courses/formatting-python-strings/"&gt;String Formatting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hackerculture.com/common-data-structures-python/"&gt;Common Data Structures in Python&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Advanced Python Topics
&lt;/h2&gt;

&lt;p&gt;This section builds upon the previous ones and teaches you how to use frameworks &amp;amp; libraries available in the Python language:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.hackerculture.com/python-asyncio-guide-to-asynchronous-programming/"&gt;Asyncio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hackerculture.com/python-threads-multithreading-guide/"&gt;Multithreading&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hackerculture.com/running-processes-python-multiprocessing-guide/"&gt;Multiprocessing&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this point in time, once you have gone through all the previous steps, you should have everything you need to make use of Python in real-world applications.&lt;/p&gt;

&lt;p&gt;Python is used in almost every industry, and you have a few career path options. Let's look at some of these.&lt;/p&gt;




&lt;h3&gt;
  
  
  Python for Web Development
&lt;/h3&gt;

&lt;p&gt;The role of a web developer is to build websites and applications that are accessible using a web browser. Python is typically used on the backend side.&lt;/p&gt;

&lt;p&gt;A popular web framework that many companies use to build web applications is &lt;strong&gt;Flask&lt;/strong&gt;. This tutorial will help you become familiar with building apps with Flask:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://realpython.com/flask-connexion-rest-api/"&gt;Python REST APIs with Flask&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should also become familiar with databases. This tutorial covers how to integrate databases with your Flask server:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://realpython.com/flask-connexion-rest-api-part-2/"&gt;Connecting a Database to your Flask Project with SQLAlchemy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also learn how to deploy Flask apps so you can share them with the world in this article:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://realpython.com/courses/deploy-python-script-web-flask/"&gt;How to deploy your Flask apps&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, you may be interested in learning more about the web and how your users will interact with your apps on their browsers. This course will help you become more of a well-rounded full-stack web developer:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.coursera.org/specializations/web-design"&gt;Web Design Course for Everybody&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Python for Automation
&lt;/h3&gt;

&lt;p&gt;Automation is the field of performing tasks that are repetitive or time-consuming, such as data entry, web scraping, and automation of various system processes, in a way that they can be reused.&lt;/p&gt;

&lt;p&gt;A specific use case for automation is the continuous testing of software projects, in which we write scripts to interact with an existing program and report errors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://realpython.com/python-testing/"&gt;Getting started with testing in Python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Automation can also be used to control other software, such as a web browser, Excel, or even hardware, such as robotic systems. Some libraries worth checking out for this are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Selenium&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Beautiful Soup&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Python for DevOps
&lt;/h3&gt;

&lt;p&gt;DevOps engineers are responsible for implementing and maintaining infrastructure to support software systems, and they work to ensure that software systems are deployed quickly, efficiently, and with minimal downtime.&lt;/p&gt;

&lt;p&gt;This book provides a comprehensive introduction to the field of DevOps:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3GToK8H"&gt;Python for DevOps: Learn Ruthlessly Effective Automation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some of the other technologies used by DevOps engineers to automate software deployments and maintain a smooth operation are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Docker&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kubernetes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Python for Data Science
&lt;/h3&gt;

&lt;p&gt;A data scientist's primary concern is to extract insights and knowledge from data. This typically involves a number of different tasks, including collecting and cleaning data, developing predictions and forecasts using statistics, and visualizing results.&lt;/p&gt;

&lt;p&gt;A data scientist must be familiar with databases and able to query large amounts of data in order to identify patterns and trends. Usually, the main tools used by data scientists are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.codecademy.com/learn/learn-sql"&gt;Free, Interactive SQL Course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pandas.pydata.org/docs/getting_started/intro_tutorials/"&gt;Pandas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.simplilearn.com/tutorials/python-tutorial/data-visualization-in-python"&gt;Data Visualization&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to get deeper into data science, consider the following books:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3vR97IT"&gt;Data Science from Scratch&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3XhZOx6"&gt;Python for Data Analysis: Data Wrangling with Pandas, NumPy, IPython&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Python for Machine Learning
&lt;/h3&gt;

&lt;p&gt;A machine learning engineer creates and develops computer programs that can "learn" from data and make predictions or decisions without being explicitly programmed to do so to solve real-world problems like predicting the weather or detecting facial expressions.&lt;/p&gt;

&lt;p&gt;This typically involves working with large sets of data, which can be explored with the &lt;strong&gt;pandas&lt;/strong&gt; library to prepare the data for use in models:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pandas.pydata.org/docs/getting_started/intro_tutorials/"&gt;Getting started with Pandas in Python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A very popular library that helps with training machine learning models for different problems is &lt;a href="https://www.simplilearn.com/tutorials/python-tutorial/scikit-learn"&gt;Scikit-learn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you are interested in building other language applications like translating speech to text or summarizing a long article, these resources are for you:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://towardsai.net/p/nlp/natural-language-processing-nlp-with-python-tutorial-for-beginners-1f54e610a1a0"&gt;Natural Language Processing (NLP) with Python - Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you prefer to read a book instead, these books are an excellent way to get into machine learning with Python:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3QwgPBB"&gt;Introduction to Machine Learning with Python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3k9sMRp"&gt;Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Tips for learning Python programming
&lt;/h3&gt;

&lt;p&gt;Learning how to write computer programs is hard, but learning Python, in particular, is significantly easier than many other programming languages. These tips will help you stay focused and motivated to achieve your goals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have patience. Learning a new language always requires more effort and time, so understand that it will take time to let everything sink in.&lt;/li&gt;
&lt;li&gt;Don't feel intimidated by complex terms, errors, and issues. Don't give up, this happens to everyone in programming. Research the topic using other resources and come back to it with a clear mind.&lt;/li&gt;
&lt;li&gt;Frustration and pain are a part of the process. Embrace them instead of avoiding them, and you will conquer them.&lt;/li&gt;
&lt;li&gt;Be consistent. If you are not consistent in learning, it will take a lot more time and effort.&lt;/li&gt;
&lt;li&gt;Don't try to learn everything at once. It's better to practice a specific topic every day before moving on to the next.&lt;/li&gt;
&lt;li&gt;Build small projects to try out the things you learn and build up your confidence. You should add them to your github profile to help you land jobs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Did you find this helpful?&lt;/strong&gt;&lt;br&gt;
I’d love to hear about it. Please let me know in the comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do you have any questions?&lt;/strong&gt;&lt;br&gt;
Leave your question in a comment below, and we'll answer it with our best advice.&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python asyncio - A Guide to Asynchronous Programming</title>
      <dc:creator>HackerCulture</dc:creator>
      <pubDate>Mon, 09 Jan 2023 22:00:13 +0000</pubDate>
      <link>https://dev.to/hackerculture/python-asyncio-a-guide-to-asynchronous-programming-43j2</link>
      <guid>https://dev.to/hackerculture/python-asyncio-a-guide-to-asynchronous-programming-43j2</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mknholxyfgm40gvmg0v.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mknholxyfgm40gvmg0v.webp" alt="Python asyncio - A Guide to Asynchronous Programming" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this guide, we'll introduce asynchronous programming in Python and review fundamental concepts like how to define, create and run asynchronous functions, coroutines, and some common use cases and best practices.&lt;/p&gt;

&lt;p&gt;You may have seen asyncio in a new project you started working on. Or perhaps in a code example of how to perform a common task:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perhaps you need to use an API and the code examples use asyncio.&lt;/li&gt;
&lt;li&gt;Or you need to integrate a new library that uses asyncio.&lt;/li&gt;
&lt;li&gt;Or you found some code snippets that use asyncio.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you understand the concepts in this guide, you will be able to develop programs that can leverage the asyncio library in Python to process many tasks concurrently and make better use of your machine resources, such as additional CPU cores.&lt;/p&gt;

&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Introduction to Asynchronous Programming&lt;/li&gt;
&lt;li&gt;Getting Started with Asyncio in Python&lt;/li&gt;
&lt;li&gt;Working with Asyncio Event Loops&lt;/li&gt;
&lt;li&gt;What Are Coroutines&lt;/li&gt;
&lt;li&gt;Using Asyncio for Network Programming&lt;/li&gt;
&lt;li&gt;Advanced Asyncio Concepts&lt;/li&gt;
&lt;li&gt;When to Use Asyncio&lt;/li&gt;
&lt;li&gt;When Not to Use Asyncio&lt;/li&gt;
&lt;li&gt;Best Practices for Asynchronous Programming in Python&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introduction to Asynchronous Programming
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous&lt;/strong&gt; refers to the concept of not occurring at the same time as something else. In the context of programming, asynchronous refers to the execution of tasks that do not block the flow of execution of other tasks. This means that multiple tasks can be performed concurrently, rather than sequentially.&lt;/p&gt;

&lt;p&gt;This is achieved by using asynchronous function calls, which return control to the calling function before the task is completed, allowing other tasks to be executed in the meantime.&lt;/p&gt;

&lt;p&gt;For example, we can make an asynchronous function call. This will issue the request to make the function call and will not wait around for the call to complete. We can choose to check on the status or result of the function call later.&lt;/p&gt;

&lt;p&gt;One of the main benefits of asynchronous programming is improved performance, as it allows for non-blocking IO operations and allows multiple tasks to be performed simultaneously.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with Asyncio in Python
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;asyncio&lt;/code&gt; module contains utilities to implement asynchronous programming in Python.&lt;/p&gt;

&lt;p&gt;It allows you to write concurrent code using asynchronous programming techniques rather than traditional thread-based concurrent programming.&lt;/p&gt;

&lt;p&gt;You may be wondering how asyncio differs from traditional thread-based concurrent programming in Python...&lt;/p&gt;

&lt;p&gt;Asyncio is particularly useful in Python because it allows you to write concurrent code in a single-threaded environment, which can be more efficient and easier to work with than using multiple threads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding the async, await syntax
&lt;/h3&gt;

&lt;p&gt;We use &lt;code&gt;def async&lt;/code&gt; to define asynchronous functions in Python. These are special types of functions that don't execute right away when called. Instead, they are scheduled, and we must then use &lt;code&gt;await&lt;/code&gt; to execute and wait for the function to return.&lt;/p&gt;

&lt;p&gt;This last point is key and is the reason why async functions are so powerful.&lt;/p&gt;

&lt;p&gt;We can also execute async functions in other parts of our program with &lt;code&gt;asyncio.run()&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async def an_async_function():
    await asyncio.sleep(1)
    print("Hello, World!")

asyncio.run(my_async_function())

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Running async functions in Python with asyncio.run&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Event Loop
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;event loop&lt;/strong&gt; is the central mechanism in asyncio that schedules and runs asynchronous tasks. It works by continuously polling for events and running the appropriate tasks when they are ready.&lt;/p&gt;

&lt;p&gt;You can think of the event loop as a kind of "coordinator" that manages the execution of asynchronous tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating and customizing event loops
&lt;/h3&gt;

&lt;p&gt;By default, asyncio will create an event loop for you when you use &lt;code&gt;asyncio.run()&lt;/code&gt; or call &lt;code&gt;asyncio.AbstractEventLoop.run_until_complete()&lt;/code&gt;. However, you can also create and customize your own event loop if needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loop = asyncio.get_event_loop()
loop.run_until_complete(an_async_function())
loop.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;How to get the current event loop&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The event loop starts with the &lt;code&gt;loop.run_until_complete()&lt;/code&gt; method, which blocks until all tasks have completed. Finally, the event loop is closed with the &lt;code&gt;loop.close()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Here are some other ways you can run an event loop in Python using the &lt;code&gt;asyncio&lt;/code&gt; module:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;loop.run_forever()&lt;/code&gt;: This method runs the event loop indefinitely. It blocks until the event loop is stopped with the &lt;code&gt;loop.stop&lt;/code&gt; method or until an exception is raised.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loop.run_until_complete(future)&lt;/code&gt;: This method runs the event loop until the given &lt;code&gt;future&lt;/code&gt; is completed. It blocks until the &lt;code&gt;future&lt;/code&gt; is done or until an exception is raised.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loop.run_in_executor(executor, func, *args)&lt;/code&gt;: This method runs the given &lt;code&gt;func&lt;/code&gt; in a thread or process executor and returns a &lt;code&gt;Future&lt;/code&gt; object. The event loop will run until the &lt;code&gt;Future&lt;/code&gt; is done or until an exception is raised.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loop.run_as_soon_as_possible(callback)&lt;/code&gt;: This method schedules the given &lt;code&gt;callback&lt;/code&gt; to be run as soon as possible. It does not block.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loop.call_later(delay, callback, *args)&lt;/code&gt;: This method schedules the given &lt;code&gt;callback&lt;/code&gt; to be run after the specified &lt;code&gt;delay&lt;/code&gt; in seconds. It does not block.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Are Coroutines
&lt;/h2&gt;

&lt;p&gt;A coroutine is a task that can be suspended and resumed. In the context of asynchronous programming, when we talk about tasks that can be performed concurrently, we are referring to coroutines.&lt;/p&gt;

&lt;p&gt;Therefore, coroutines are the unit of concurrency used in asyncio programs.&lt;/p&gt;

&lt;p&gt;Many coroutines can be created and executed at the same time. They have control over when they will suspend and resume, allowing them to cooperate as to when concurrent tasks are executed.&lt;/p&gt;

&lt;p&gt;This is called &lt;strong&gt;cooperative multitasking&lt;/strong&gt; and is different from the multitasking typically used with threads called &lt;em&gt;preemptive multitasking&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A coroutine can be defined using the &lt;code&gt;async def&lt;/code&gt; expression. It can take arguments and return a value, just like a function. Calling a coroutine function will create a coroutine object, but it &lt;strong&gt;does not&lt;/strong&gt; execute the coroutine function right away.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async def my_coroutine(delay):
    await asyncio.sleep(delay)
    print(f'Finished waiting for {delay} seconds')

# creates but does not execute the coroutine
coroutine_1 = my_coroutine(1)
# await starts the coroutine and blocks until finished
result = await my_coroutine(2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Creating and awaiting coroutines&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When a coroutine is created but never executed, we will see a warning like this when the Python program finishes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sys:1: RuntimeWarning: coroutine 'my_coroutine' was never awaited
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can avoid this warning and support top-level &lt;code&gt;await&lt;/code&gt; expressions by starting the Python interpreter with a default event loop. This is also the default in IPython.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m asyncio script.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Having top level &lt;code&gt;await&lt;/code&gt; is neat, but it can cause problems too. There can only be one event loop running in a thread. If any of your code tries to launch an event loop, perhaps by calling &lt;code&gt;asyncio.run()&lt;/code&gt;, you'll get an error, so be careful.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's so great about coroutines
&lt;/h3&gt;

&lt;p&gt;Threads and processes achieve multitasking managed by the operating system (OS) that chooses which threads and processes should run, when, and for how long. The OS switches between threads and processes rapidly, suspending those that are not running and resuming those granted time to run. This is called &lt;strong&gt;preemptive multitasking&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Coroutines in Python provide an alternative type of multitasking called &lt;strong&gt;cooperating multitasking&lt;/strong&gt;. This allows coroutines to cooperate by design, choosing how and when to suspend their execution.&lt;/p&gt;

&lt;p&gt;Another key aspect of coroutines is that they are more lightweight than threads. This means they are faster to start and use less memory. They may use less than 1 KB of memory to execute. Essentially a coroutine is a special type of function, whereas a thread is represented by a Python object associated with an operating system thread with which the object must interact.&lt;/p&gt;

&lt;p&gt;Coroutines are a new alternate, interesting, and powerful approach to concurrency, different from thread-based and process-based concurrency. As such, we may have thousands of threads in a Python program, but we could easily have tens or hundreds of thousands of coroutines just in one thread.&lt;/p&gt;

&lt;p&gt;You can also schedule coroutines for execution in separate threads, with &lt;code&gt;ThreadPoolExecutor&lt;/code&gt;, or separate processes using &lt;code&gt;ProcessPoolExecutor&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Run Blocking Tasks with Asyncio
&lt;/h3&gt;

&lt;p&gt;We often need to execute a blocking function call within an asyncio application because, in practice, most workloads include a mix of IO-bound operations and also CPU-bound operations.&lt;/p&gt;

&lt;p&gt;This could be for many reasons, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To execute a CPU-bound task like calculating something.&lt;/li&gt;
&lt;li&gt;To execute a blocking IO-bound task like reading or writing from a file.&lt;/li&gt;
&lt;li&gt;To call into a third-party library that does not support asyncio yet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Making a blocking call directly in an asyncio program will cause the event loop to stop while the blocking call is executing. It will not allow other coroutines to run in the background.&lt;/p&gt;

&lt;p&gt;This can be prevented by running the blocking call outside of the event loop, which we can do with &lt;code&gt;asyncio.to_thread()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# execute a function in a separate thread
await asyncio.to_thread(my_blocking_task)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;How to run blocking task with asyncio&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;code&gt;asyncio.to_thread()&lt;/code&gt;&lt;/strong&gt; function takes a function to execute and any arguments. It returns a coroutine that can be awaited or scheduled as an independent task. The function is then executed in a separate thread.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;code&gt;asyncio.to_thread()&lt;/code&gt;&lt;/strong&gt; function creates a &lt;strong&gt;&lt;code&gt;ThreadPoolExecutor&lt;/code&gt;&lt;/strong&gt; behind the scenes to execute blocking calls.&lt;/p&gt;

&lt;p&gt;As such, the &lt;code&gt;asyncio.to_thread()&lt;/code&gt; function is only appropriate for IO-bound tasks, and we should not use this method of asyncio for CPU bound tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Asyncio for Network Programming
&lt;/h2&gt;

&lt;p&gt;Network calls are a good use case for asyncio since they're IO-bound, and we can just fire and forget the write or read_,_ and our program can go on to perform other tasks. The caller does not need to wait for the operation to complete before returning, so we should not waste time just checking on them.&lt;/p&gt;

&lt;p&gt;The read and write operations are performed somehow (e.g., by the underlying operating system or perhaps a task queue like Kafka), and the status of the action and/or data is retrieved by the caller later, once available, or when the caller is ready.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-blocking&lt;/strong&gt; IO is a way of performing IO where reads and writes are requested, although performed asynchronously. The caller does not need to wait for the operation to complete before returning. Non-blocking IO is implemented in practice with asynchronous programming.&lt;/p&gt;

&lt;p&gt;Let's go through a few asyncio examples that implement non-blocking IO in client and server networking:&lt;/p&gt;

&lt;h3&gt;
  
  
  HTTP server
&lt;/h3&gt;

&lt;p&gt;This is an example of an asyncio-based HTTP server that serves static files from a given directory. It uses the &lt;code&gt;aiohttp&lt;/code&gt; library to handle HTTP requests and responses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import asyncio
from aiohttp import web

async def handle(request):
    with open('index.html', 'rb') as f:
        return web.Response(body=f.read(), content_type='text/html')

async def main():
    app = web.Application()
    app.add_routes([web.get('/', handle)])
    return app

if __name__ == ' __main__':
    web.run_app(main())

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Async web server in Python&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  WebSocket server
&lt;/h3&gt;

&lt;p&gt;This is an example of an asyncio-based WebSocket server that broadcasts messages to all connected clients. It uses the &lt;code&gt;websockets&lt;/code&gt; library to handle WebSocket connections.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import asyncio
import websockets

async def broadcast(websockets, message):
    for ws in websockets:
        await ws.send(message)

async def handler(websocket, path):
    async for message in websocket:
        await broadcast(websockets, message)

async def main(host, port):
    server = await websockets.serve(handler, host, port)
    await server.wait_closed()

if __name__ == ' __main__':
    asyncio.run(main('127.0.0.1', 8888))

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Async websockets server and handlers&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  WebSocket client
&lt;/h3&gt;

&lt;p&gt;This is an example of an asyncio-based WebSocket client that connects to a server, sends a message, and prints the response. It uses the &lt;code&gt;websockets&lt;/code&gt; library to handle the WebSocket connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import asyncio
import websockets

async def main():
    async with websockets.connect('ws://localhost:8888') as websocket:
        await websocket.send("Hello, world!")
        response = await websocket.recv()
        print(f'Received: {response}')

asyncio.run(main())

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Async websockets client connections&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced Asyncio Concepts
&lt;/h2&gt;

&lt;p&gt;So far, we've only seen examples of how to run a single asynchronous function to perform non-blocking IO operations.&lt;/p&gt;

&lt;p&gt;When we have many operations to run concurrently, we need to coordinate and manage those operations. Fortunately, the asyncio module has some functions that make it easier for us.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use asyncio.gather() to wait for multiple async tasks
&lt;/h3&gt;



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

async def task_one():
    print("Starting task one")
    await asyncio.sleep(1)
    print("Finishing task one")
    return 1

async def task_two():
    print("Starting task two")
    await asyncio.sleep(2)
    print("Finishing task two")
    return 2

async def main():
    # This will wait for all the coroutines
    results = await asyncio.gather(task_one(), task_two())
    print(results)

asyncio.run(main())

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Using asyncio.gather to wait for coroutines&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This code will produce the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Starting task one
Starting task two
Finishing task one
Finishing task two
[1, 2]

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

&lt;/div&gt;



&lt;p&gt;As you can see, the tasks are run concurrently rather than sequentially. This can be useful for improving the performance of an application by allowing it to make better use of available CPU resources.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;asyncio.gather()&lt;/code&gt; method accepts many arguments and returns a list of the results returned by all the coroutines.&lt;/p&gt;

&lt;p&gt;It is also common to create many coroutines beforehand and then gather them later. We can collect many coroutines together into a list either manually or using a list comprehension. We can then unpack this list as arguments to &lt;code&gt;gather()&lt;/code&gt;. Note the use of the star operator (&lt;code&gt;*&lt;/code&gt;) here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# creates many coroutines
coros = [my_async_task(i) for i in range(10)]
...
# then, run the tasks
results = await asyncio.gather(*coros)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;How to await a list of coroutines using asyncio.gather&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use asyncio.wait() to manage multiple asynchronous tasks
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;asyncio.wait()&lt;/code&gt; function blocks and returns a tuple containing two sets of tasks: those that have completed and those that are still pending. In this example, we iterate over the completed tasks and print their results.&lt;/p&gt;

&lt;p&gt;Using the &lt;code&gt;asyncio.wait()&lt;/code&gt; function, you can easily manage multiple asynchronous tasks and perform actions when they have completed. This can be particularly useful for situations where you need to wait for multiple tasks to complete before moving on to the next step of your program and for setting timeouts for some tasks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Run these tasks and wait 
tasks = [task_one(), task_two()]
    completed, pending = await asyncio.wait(tasks)

    results = [t.result() for t in completed]
    print(results)

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Using asyncio.wait to manage async tasks&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, we could use the &lt;code&gt;asyncio.as_completed()&lt;/code&gt; function to run concurrent tasks and iterate their results as they become available. This is possible because &lt;code&gt;asyncio.as_completed()&lt;/code&gt; returns an iterable of the coroutines that can be awaited.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chaining multiple asynchronous tasks
&lt;/h3&gt;

&lt;p&gt;There are situations where you may need to perform a series of asynchronous tasks in a specific order. Since coroutines are awaitable, another coroutine can &lt;code&gt;await&lt;/code&gt; it. You may use this class to chain async tasks since the &lt;code&gt;asyncio&lt;/code&gt; library does not (yet) provide a similar function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Chain:
    "A class to execute async tasks sequentially"
    def __init__ (self, tasks):
        self.tasks = tasks

    async def __call__ (self, *args, **kwargs):
        for task in self.tasks:
            args = await task(*args, **kwargs)
            args = (result,)
        return result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;The Chain class executes async tasks sequentially&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To use this class, you can pass a list of asynchronous tasks to the constructor and then call the &lt;code&gt;Chain&lt;/code&gt; instance to execute the tasks in the specified order. The result of each task is passed as an argument to the next task in the chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chain = Chain([task_one, task_two])
# block until tasks are performed synchronously
result = await chain() # returns the last task result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Running tasks in sequence with Chain&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When to Use Asyncio
&lt;/h2&gt;

&lt;p&gt;Coroutines are an alternative to threading-based concurrency that is provided by the Python language and further supported by the asyncio module. They are suited to non-blocking IO with subprocesses and sockets. However, blocking IO and CPU-bound tasks can be used in a simulated non-blocking manner using threads and processes under the covers.&lt;/p&gt;

&lt;p&gt;Any program written using threads or processes can be rewritten or instead written using coroutines if we so desire.&lt;/p&gt;

&lt;p&gt;A coroutine is even more lightweight than a process. Processes, like threads, are created and managed by the underlying operating system and are represented by a &lt;strong&gt;multiprocessing.Process&lt;/strong&gt; object.&lt;/p&gt;

&lt;p&gt;This means that coroutines are significantly faster than a process to create and start and take up much less memory. A coroutine is just a special function, whereas a Process is an instance of the interpreter that has at least one thread.&lt;/p&gt;

&lt;p&gt;As such, we may have thousands of threads in a Python program, but we could easily have tens or hundreds of thousands of coroutines all in one thread.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Not to Use Asyncio
&lt;/h2&gt;

&lt;p&gt;There are many misconceptions about Python concurrency and especially around asyncio. Using &lt;code&gt;asyncio&lt;/code&gt; does not magically solve all the issues with Python.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Asyncio works around the Global Interpreter Lock (GIL).&lt;/li&gt;
&lt;li&gt;Asyncio is faster than using threads.&lt;/li&gt;
&lt;li&gt;Asyncio avoids the need for locks and other synchronization methods.&lt;/li&gt;
&lt;li&gt;Asyncio is easier to use than threads.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are all &lt;strong&gt;False&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Only a single coroutine can run at a time by design, and they cooperate to execute. This is just like threads under the GIL. However, the GIL still applies to &lt;code&gt;asyncio&lt;/code&gt; code, and the performance of &lt;code&gt;asyncio&lt;/code&gt; programs may be affected by the GIL in the same way as multithreaded programs. So &lt;code&gt;asyncio&lt;/code&gt; is not faster and is also not multithreaded and not parallel.&lt;/p&gt;

&lt;p&gt;Any program you can write with &lt;code&gt;asyncio&lt;/code&gt;, you can also write with threads, and it could actually be as fast or even faster. It could also probably be simpler and easier to read and interpret by other developers.&lt;/p&gt;

&lt;p&gt;If you need to bypass the GIL and take full advantage of multiple CPU cores in your Python program, you may want to consider using a different concurrency framework like &lt;code&gt;multiprocessing&lt;/code&gt; and other libraries such as &lt;code&gt;concurrent.futures&lt;/code&gt;. These frameworks allow you to create multiple processes, each with its own Python interpreter and GIL, which can run in parallel on separate CPU cores.&lt;/p&gt;

&lt;p&gt;Any concurrency pitfalls you might expect with threads, you can also encounter with coroutines. You must ensure coroutines are thread safe and safe from deadlocks and race conditions, just like with threads or processes.&lt;/p&gt;

&lt;p&gt;Another reason not to use &lt;code&gt;asyncio&lt;/code&gt; is that you may not like asynchronous programming. Even though asynchronous programming has been popular for some time now in various programming communities, it is different from procedural, object-oriented, and functional programming, and some developers just don’t like it.&lt;/p&gt;

&lt;p&gt;If you don’t like it, don’t use it. It’s a fair reason.&lt;/p&gt;

&lt;p&gt;You can achieve concurrency in many ways other than using asynchronous programming, using threads or processes as needed.&lt;/p&gt;

&lt;p&gt;You can learn all about threads and processes in our guides:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.hackerculture.com/running-processes-python-multiprocessing-guide/" rel="noopener noreferrer"&gt;Running multiple processes in Python - a multiprocessing guide&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Asynchronous Programming in Python
&lt;/h2&gt;

&lt;p&gt;These are some tips that will have you writing efficient and maintainable asynchronous code and save you lots of headaches:&lt;/p&gt;

&lt;h3&gt;
  
  
  Use asyncio's high-level APIs whenever possible
&lt;/h3&gt;

&lt;p&gt;The asyncio library provides several high-level APIs that make it easy to write concurrent code. For example, you can use the &lt;code&gt;gather&lt;/code&gt; function to run multiple tasks concurrently or the &lt;code&gt;as_completed&lt;/code&gt; function to iterate over a group of tasks as they complete. These APIs can help you write efficient and maintainable code, as they abstract away many of the low-level details of concurrent programming.&lt;/p&gt;

&lt;h3&gt;
  
  
  Avoid blocking the event loop
&lt;/h3&gt;

&lt;p&gt;The event loop is the heart of asyncio, and it is responsible for scheduling and executing asynchronous tasks. If you block the event loop, you can cause performance issues and disrupt the execution of other tasks. To avoid blocking the event loop, use non-blocking IO operations whenever possible, and avoid using blocking functions such as &lt;code&gt;time.sleep&lt;/code&gt; or &lt;code&gt;threading.Lock&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use async context managers and async iterators
&lt;/h3&gt;

&lt;p&gt;Async context managers and async iterators can help you write asynchronous code that is easy to understand and maintain. For example, you can use async context managers to manage resources that need to be acquired and released asynchronously, or you can use async iterators to iterate over asynchronous data streams in a natural and intuitive way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common pitfalls to avoid when doing asynchronous programming
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Forgetting to &lt;code&gt;await&lt;/code&gt; asynchronous tasks: When you &lt;code&gt;await&lt;/code&gt; an asynchronous task, you are telling the event loop to execute that task and pause the current task until the awaited task completes. If you forget to &lt;code&gt;await&lt;/code&gt; a task, it will be scheduled to run, but the event loop will not wait for it to complete before moving on to the next task. This can lead to unexpected behavior and race conditions.&lt;/li&gt;
&lt;li&gt;Not using asynchronous functions when appropriate: On the other hand, it is important to use asynchronous functions when appropriate, as this can significantly improve the performance and scalability of your application. If you have long-running tasks or tasks that perform IO operations, consider using asynchronous functions to ensure that they do not block the event loop.&lt;/li&gt;
&lt;li&gt;Not using synchronization techniques: Any concurrency pitfalls you might expect with threads, you can also encounter with coroutines. While only one coroutine can run within the event loop at one time, they can be suspended and resumed while using a shared variable. You must ensure coroutines are safe from deadlocks and race conditions, just like with threads or processes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you keep these practices in mind and avoid the multiple pitfalls related to concurrency and asynchronous programming, you should be able to develop Python programs that can process many tasks concurrently.&lt;/p&gt;

&lt;p&gt;You may even want to experiment with running asynchronous tasks combined with other concurrency techniques, especially when pairing asyncio with multiprocessing and  &lt;a href="https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor" rel="noopener noreferrer"&gt;concurrent.futures.Executor&lt;/a&gt; instances.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.python.org/3/library/asyncio-eventloop.html" rel="noopener noreferrer"&gt;Event Loop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.python.org/3/library/asyncio-task.html" rel="noopener noreferrer"&gt;Coroutines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://amzn.to/3Q47hh3" rel="noopener noreferrer"&gt;Using Asyncio in Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://superfastpython.com/python-asyncio/" rel="noopener noreferrer"&gt;Python Asyncio The Complete Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How are you using asyncio in your programs?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
I’d love to hear about it. Please let me know in the comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do you have any questions?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Leave your question in a comment below, and I'll answer it with my best advice.&lt;/p&gt;

</description>
      <category>python</category>
      <category>concurrency</category>
      <category>asyncio</category>
      <category>asynchronous</category>
    </item>
    <item>
      <title>Why I Started the Atomic-fns Library</title>
      <dc:creator>HackerCulture</dc:creator>
      <pubDate>Sat, 05 Nov 2022 15:00:11 +0000</pubDate>
      <link>https://dev.to/hackerculture/why-i-started-the-atomic-fns-library-443d</link>
      <guid>https://dev.to/hackerculture/why-i-started-the-atomic-fns-library-443d</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0CfJBhEk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.hackerculture.com/content/images/2023/01/norbert-kowalczyk-jrKKj9nJMxM-unsplash.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0CfJBhEk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.hackerculture.com/content/images/2023/01/norbert-kowalczyk-jrKKj9nJMxM-unsplash.webp" alt="Why I Started the Atomic-fns Library" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open source is more important than ever, and more companies are realizing the benefits and increasing their adoption. As long as it's something popular that can speed up the development process, why not use it? It doesn't cost anything!&lt;/p&gt;

&lt;p&gt;Well, it doesn't cost &lt;em&gt;money&lt;/em&gt;... But I've found there are more subtle costs that could end up having a huge impact on the business, and we should consider them before introducing any dependencies to existing products or processes.&lt;/p&gt;

&lt;p&gt;There's the cost of distributing the libraries you're using (and their dependencies) to your customers in your builds. That means your customers need to download a larger bundle, which makes their experience a bit slower.&lt;/p&gt;

&lt;p&gt;There's the maintenance cost of outdated libraries, which often include outdated dependencies. Those could have known vulnerabilities with known exploits (and fixes), which can damage the brand, business, and customers.&lt;/p&gt;

&lt;p&gt;When a library is no longer maintained, it's almost impossible to get support or request new features. The issues pile up on an endless list of open bugs. And those bugs are almost never fixed when you need them to be. You can count on Murphy's Law to kick in here.&lt;/p&gt;

&lt;p&gt;Then there's the cost of the workarounds. Once you start uncovering bugs and you realize nobody is coming to save you, there are two possible outcomes: you either stop using that library, or you try to make it work on your own, taking on weeks of additional work.&lt;/p&gt;

&lt;p&gt;On the other hand, there are specific characteristics that separate the quality open-source projects from their abandoned counterparts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bundle sizes.&lt;/strong&gt; Good projects are modular, so you can import only what you need and keep your bundle sizes low. JavaScript libraries can be checked using &lt;a href="https://bundlephobia.com/"&gt;bundlephobia.com&lt;/a&gt; – also, look for libraries that are &lt;a href="https://www.smashingmagazine.com/2021/05/tree-shaking-reference-guide/"&gt;tree-shakeable&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source code.&lt;/strong&gt; If you aren't able to inspect the code, &lt;em&gt;don't use it because it could explode&lt;/em&gt;. But also, is the code clear? Are there comments? Could you explain how it works to others?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Up to date.&lt;/strong&gt; Look at the commit history. Are there recent commits and bug fixes landed? Are they keeping their dependencies up to date?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test coverage.&lt;/strong&gt; If there are no tests, how do we know the code does what it's supposed to do? Browse through the tests and make sure that they cover enough cases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open issues.&lt;/strong&gt; Check the project's open issues to make sure the maintainers are active and listening. Check for a roadmap too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No vulnerabilities.&lt;/strong&gt; Run &lt;code&gt;npm audit&lt;/code&gt; after adding a new dependency to check that it doesn't introduce vulnerabilities. Bonus points if the library you plan to use has zero dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation.&lt;/strong&gt; Can you find available docs that show how the library is meant to be used? Official or otherwise, having something you can refer to and share with other team members is super valuable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Recently, I've had to estimate these costs when deciding on which libraries to use for a new project and was considering using the popular &lt;code&gt;lodash&lt;/code&gt; library. Until I started looking at their long list of &lt;a href="https://github.com/lodash/lodash/issues"&gt;open bugs&lt;/a&gt;, realizing this project has been dead for the past 6 years, and then I read their source code, ridden with custom macros and over-engineered abstractions (see &lt;a href="https://github.com/lodash/lodash/blob/master/clone.js"&gt;clone&lt;/a&gt;). And then it hit me...&lt;/p&gt;

&lt;p&gt;This must be why there are so many open bugs. It takes so much effort to understand just one basic function that most people won't even try. Hell, even the original maintainers probably can't understand it at this point because of all the abstractions.&lt;/p&gt;

&lt;p&gt;So I started working on a &lt;a href="https://github.com/adrian2x/atomic-fns"&gt;similar library&lt;/a&gt; to replace my &lt;code&gt;lodash&lt;/code&gt; imports, and a handful of other libraries. But the main goal is that it should be easy to learn, easy to test, and easy to maintain. There are plenty of &lt;a href="https://atomic-fns.dev/"&gt;docs&lt;/a&gt; available to get you started, and I hope you join the conversation on &lt;a href="https://github.com/adrian2x/atomic-fns"&gt;github&lt;/a&gt; to help shape its future.&lt;/p&gt;

&lt;p&gt;[&lt;/p&gt;

&lt;p&gt;GitHub - adrian2x/atomic-fns: Like Lodash, but for ESNext and with types.&lt;/p&gt;

&lt;p&gt;Like Lodash, but for ESNext and with types. Contribute to adrian2x/atomic-fns development by creating an account on GitHub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EC2gQHPC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/fluidicon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EC2gQHPC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/fluidicon.png" alt="Why I Started the Atomic-fns Library" width="512" height="512"&gt;&lt;/a&gt;GitHubadrian2x&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4i_KYmLY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://opengraph.githubassets.com/91028d389e69e00d4f5a284ae39e5af0d08cec7b20c84e30e4ed6d3f5c3bdaf5/adrian2x/atomic-fns" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4i_KYmLY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://opengraph.githubassets.com/91028d389e69e00d4f5a284ae39e5af0d08cec7b20c84e30e4ed6d3f5c3bdaf5/adrian2x/atomic-fns" alt="Why I Started the Atomic-fns Library" width="880" height="440"&gt;&lt;/a&gt;&lt;br&gt;
](&lt;a href="https://github.com/adrian2x/atomic-fns"&gt;https://github.com/adrian2x/atomic-fns&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>opinion</category>
    </item>
    <item>
      <title>A Gentle Introduction to Python Programming</title>
      <dc:creator>HackerCulture</dc:creator>
      <pubDate>Fri, 28 Jan 2022 14:00:00 +0000</pubDate>
      <link>https://dev.to/hackerculture/a-gentle-introduction-to-python-programming-344l</link>
      <guid>https://dev.to/hackerculture/a-gentle-introduction-to-python-programming-344l</guid>
      <description>&lt;p&gt;Programming offers a chance to develop creativity, reasoning, and problem-solving skills. As a programmer, you get to bring ideas to life through code and using logic to create programs that can be executed by a computer.&lt;/p&gt;

&lt;p&gt;If you know how to write computer programs, you can do all sorts of useful things. You might not be able to write programs to control cars, traffic lights, or your fridge right away, but you could make web pages, your own games, or even a program to help you with your homework.&lt;/p&gt;

&lt;p&gt;When faced with obstacles, programming requires you to use problem-solving to find solutions. While it can be challenging (and at times frustrating), programming is also a fun and rewarding activity! The skills gained from programming can be beneficial in multiple professions, even if your chosen career is not directly related to computers.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Learn to Code
&lt;/h2&gt;

&lt;p&gt;Like anything you try for the first time, it’s always best to start with the basics. Gymnasts don't usually do backflips on their first try. If you jump ahead too quickly, not only will the basic ideas not stick in your head, but you’ll also find the content of the later articles more complicated than it actually is.&lt;/p&gt;

&lt;p&gt;Remember that the better you understand the basics, the easier it will be to understand more complicated ideas later on. When you find something frustrating or too challenging, here are some things that I find helpful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Break a problem down into smaller pieces. Try to understand what a small piece of code is doing or think about only a small part of a difficult idea (focus on a small piece of code rather than trying to understand the whole thing at once).&lt;/li&gt;
&lt;li&gt;If that still doesn’t help, it might be best to leave it alone for a while. Sleep on it and come back to it another day. This is a good way to solve many problems, and it can be particularly helpful for computer programmers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is a Computer Program
&lt;/h2&gt;

&lt;p&gt;A program is a list of steps for a computer to follow. Programs are made up of lines of code. Each line tells the computer something specific about how to follow these instructions.&lt;/p&gt;

&lt;p&gt;Software is a collection of computer programs.&lt;/p&gt;

&lt;p&gt;Programs are like thoughts. If you didn’t have thoughts, you would probably just sit on the couch all day, staring at the ceiling. Your thought “get up off the couch” is a command or instruction that tells your body to stand up. In the same way, computer programs use commands to tell computers what to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Python Programming Language
&lt;/h3&gt;

&lt;p&gt;Like humans, computers use multiple languages to communicate—these are called programming languages. A programming language is simply a way to talk to a computer by using instructions that both humans and computers can understand.&lt;/p&gt;

&lt;p&gt;The Python programming language has many features that make it extremely useful for beginners. Most importantly, you can use Python to write simple, efficient programs quite quickly. Python doesn’t use as many complicated symbols as other programming languages, which makes it easier to read and a lot friendlier for beginners.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Python programming language was actually named after the Monty Python’s Flying Circus TV show, not after the snake.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;To install Python, navigate to &lt;a href="https://python.org/downloads"&gt;python.org/downloads&lt;/a&gt; and click on Download Python. At the time of this writing, the latest version is 3.11.1. Make sure you download a version higher than 3.10.&lt;/p&gt;

&lt;p&gt;Once downloaded, double-click the file to run the installer.&lt;br&gt;
Make sure you select &lt;strong&gt;Add Python to PATH&lt;/strong&gt;, and accept all the defaults as you click through the installer.&lt;/p&gt;

&lt;p&gt;When the setup is complete, you will find your Python folder inside the Applications folder on your computer.&lt;/p&gt;

&lt;p&gt;Now that you have Python installed, we can write our first program!&lt;/p&gt;
&lt;h3&gt;
  
  
  For Windows
&lt;/h3&gt;

&lt;p&gt;Search for the &lt;strong&gt;Command&lt;/strong&gt; application in the Start Menu or the Windows search box.&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;python&lt;/code&gt; in all lowercase. You should see a message from Python like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python
Python 3.11.0 &lt;span class="o"&gt;(&lt;/span&gt;main, Jan  9 2023, 15:58:34&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;Clang 14.0.0 &lt;span class="o"&gt;(&lt;/span&gt;clang-1400.0.29.202&lt;span class="o"&gt;)]&lt;/span&gt; on darwin
Type &lt;span class="s2"&gt;"help"&lt;/span&gt;, &lt;span class="s2"&gt;"copyright"&lt;/span&gt;, &lt;span class="s2"&gt;"credits"&lt;/span&gt; or &lt;span class="s2"&gt;"license"&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;more information.
&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;Here, you can play around with the Python interpreter. Note the three greater-than signs (&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;) are called the &lt;em&gt;prompt&lt;/em&gt;. This means Python is waiting for our input.&lt;/p&gt;
&lt;h3&gt;
  
  
  For Mac
&lt;/h3&gt;

&lt;p&gt;Python is already installed on most Macs, but it's probably an outdated version and not the one you want.&lt;/p&gt;

&lt;p&gt;To see which version of Python is installed, open the &lt;strong&gt;Terminal&lt;/strong&gt; application from the Applications folder and enter &lt;code&gt;python3&lt;/code&gt;. You should then see the Python version and prompt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; A shell window (or terminal) is a command-line interface on a computer where you can type commands to the operating system and receive text output in return.&lt;/p&gt;

&lt;p&gt;Enter the following line into the prompt:&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;You should see the "Hello World" line printed out.&lt;/p&gt;

&lt;p&gt;To close the terminal session, press &lt;code&gt;Ctrl-Z&lt;/code&gt; and Enter, or type &lt;code&gt;exit()&lt;/code&gt; and press Enter.&lt;/p&gt;

&lt;p&gt;But wait a second... you may be thinking, "How is this useful?". That's a totally fair question. Let's look at a more realistic example.&lt;/p&gt;

&lt;p&gt;Copy and paste the following code into your Python shell, and press Enter.&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@HackerCulture/datetime?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;



&lt;p&gt;You should now see today's date and time printed out!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In Python, the hash symbol (&lt;code&gt;#&lt;/code&gt;) indicates a comment. Anything following a hash char in your code is ignored by Python; they are just there for human readers. You can use comments to write notes in plain English within your programs.&lt;/p&gt;

&lt;p&gt;Comments can also be used to experiment with your code. If you want to temporarily "turn off" some code so that it doesn't run but don't want to delete it entirely, start the line with a #. This will convert the line into a comment, which Python will ignore when running the program.&lt;/p&gt;

&lt;p&gt;Let's take a look at the code starting with this line:&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;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This imports a module called &lt;code&gt;datetime&lt;/code&gt; from &lt;em&gt;somewhere&lt;/em&gt;, which we will use to display the current date and time. For now, you probably have no idea where it's coming from, and that's completely okay.&lt;/p&gt;

&lt;p&gt;The second line is a bit different:&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;today&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It kind of sounds like this line is saying: &lt;code&gt;today is equal to a datetime now&lt;/code&gt;, maybe? Or more like &lt;code&gt;today is datetime now&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That's pretty much exactly what this line does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It creates a new variable name called "today".&lt;/li&gt;
&lt;li&gt;It assigns the result of &lt;code&gt;datetime.now()&lt;/code&gt; to the variable &lt;code&gt;today&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, this prints out the value of the variable &lt;code&gt;today&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, try to change the name &lt;code&gt;today&lt;/code&gt; in the last line to something else, like &lt;code&gt;now&lt;/code&gt;, and run the code again.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do if you see an error
&lt;/h2&gt;

&lt;p&gt;You may see an error this time, and the output is just the Python interpreter telling us where the problem is.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Traceback &lt;span class="o"&gt;(&lt;/span&gt;most recent call last&lt;span class="o"&gt;)&lt;/span&gt;:
  File &lt;span class="s2"&gt;"/var/shared-data/code/main.py"&lt;/span&gt;, line 6, &lt;span class="k"&gt;in&lt;/span&gt; &amp;lt;module&amp;gt;
    print&lt;span class="o"&gt;(&lt;/span&gt;now&lt;span class="o"&gt;)&lt;/span&gt;
          ^^^
NameError: name &lt;span class="s1"&gt;'now'&lt;/span&gt; is not defined. Did you mean: &lt;span class="s1"&gt;'pow'&lt;/span&gt;?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;NameError&lt;/code&gt; happens when we either forget to set a variable's name before using it or we made a spelling error when entering the variable name.&lt;/p&gt;

&lt;p&gt;The output also reports that this error happened in line 6 of the file &lt;code&gt;main.py&lt;/code&gt;. This can help us spot the error quickly.&lt;/p&gt;

&lt;p&gt;If we change both of these lines to use the same name "now", the code works again. Try copying these lines into your shell now:&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;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&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;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many programming mistakes are simple typos of one character in one line of code. If you spend a long time trying to find one of these mistakes, you're not alone. Many skilled and experienced programmers spend hours looking for these types of small mistakes. Try to laugh about it and move on, knowing that this will happen a lot as you learn to code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Variables and Operations
&lt;/h2&gt;

&lt;p&gt;Variables are a way of storing things in a program. They're essentially a way to name a value, and they point to the given value in memory. Their value can later be retrieved and used in expressions.&lt;/p&gt;

&lt;p&gt;To create a variable, we simply type the name on the left side of an equal sign (&lt;code&gt;=&lt;/code&gt;). The right side must be an expression. This can be a primitive value or a more complicated expression.&lt;/p&gt;

&lt;p&gt;For example, we can assign the result of a calculation to a variable:&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;weeks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;
&lt;span class="n"&gt;days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;
&lt;span class="n"&gt;vacation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;workdays&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;days&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;vacation&lt;/span&gt;
&lt;span class="n"&gt;workweeks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;workdays&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;7&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;workdays&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find the value of a variable, we can use print followed by the name of the variable in parentheses. Try copying the code above to your shell, and then press Enter.&lt;/p&gt;

&lt;p&gt;We can also tell Python to change the variable so that it contains a new value and also use more than one name or variable for the same value:&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;days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;span class="n"&gt;week&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;days&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;week&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we're changing the value of the variable &lt;code&gt;days&lt;/code&gt; to 7 and then, we're saying that we want the variable &lt;code&gt;week&lt;/code&gt; to refer to the current value of the variable days.&lt;/p&gt;

&lt;p&gt;However, &lt;code&gt;week&lt;/code&gt; isn't a very useful name for a variable because it doesn't tell us much about what the variable is used for. Let's call our variable &lt;code&gt;days_in_week&lt;/code&gt; instead.&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;days_in_week&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&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;days_in_week&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes it clear that we're talking about the number of days in a week.&lt;/p&gt;

&lt;p&gt;Variable names can be made up of letters, numbers, and underscores (_), but they can't start with a number.&lt;/p&gt;

&lt;p&gt;You can use any lowercase letters for variable names, but the name cannot contain a space, so we use underscores to separate words.&lt;/p&gt;

&lt;p&gt;You should not use uppercase letters in variable names because they have a special meaning that we'll discuss another time. Python is a case-sensitive language, which means that &lt;code&gt;today&lt;/code&gt; is not the same as &lt;code&gt;Today&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The order of operations
&lt;/h3&gt;

&lt;p&gt;You can do all the basic math operations in Python using the corresponding operators, as you saw in that example.&lt;/p&gt;

&lt;p&gt;We use parentheses in programming languages to control the order of operations. An operation is anything that uses an operator. Multiplication and division have a higher order than addition and subtraction, so they’re performed first. In other words, if you enter an equation in Python, multiplication or division is performed before addition or subtraction.&lt;/p&gt;

&lt;p&gt;For example, in this expression, the numbers 2 and 10 are multiplied first, and then the number 5 is added to the product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5 + 2 * 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is &lt;code&gt;25&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We can change the order of operations (and the result) by adding the parentheses around the numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(5 + 2) * 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result of this expression is now &lt;code&gt;70&lt;/code&gt; because the parentheses tell Python to add &lt;code&gt;5&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt;, and then multiply the result by &lt;code&gt;10&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Parentheses can be nested, which means that there can be parentheses inside parentheses, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;((5 + 2) * 10) / 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, Python evaluates the innermost parentheses first, then the outer ones, and then the final division. So it adds &lt;code&gt;5&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt;, then multiplies the result by &lt;code&gt;10&lt;/code&gt;, and then divides that by &lt;code&gt;7&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Saving Your Python Programs
&lt;/h2&gt;

&lt;p&gt;As we saw, we can write Python code directly into the shell window... but Python programs wouldn’t be very useful if you needed to rewrite them every time you wanted to use them.&lt;/p&gt;

&lt;p&gt;Sure, it might be fine for short programs, but a large program could have millions of lines of code!&lt;/p&gt;

&lt;p&gt;Luckily, we can save our programs for future use.&lt;br&gt;
To create and save a new program, enter &lt;code&gt;idle&lt;/code&gt; in the Windows search box, and select &lt;strong&gt;IDLE (Python 3.11.1 64-bit)&lt;/strong&gt;. In a Mac, open your Applications folder and open the &lt;strong&gt;Python 3.11&lt;/strong&gt; folder to find IDLE.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---qCQqEh_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02ox0a04jlzf2840m8ge.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---qCQqEh_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02ox0a04jlzf2840m8ge.png" alt="The IDLE python shell" width="667" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;IDLE (Integrated DeveLopment Environment) is a Python file editor which let you write programs in Python.&lt;/p&gt;

&lt;p&gt;When you open IDLE, you will see the Python shell. Click &lt;strong&gt;File › New Window&lt;/strong&gt;. An empty window will appear.&lt;/p&gt;

&lt;p&gt;Paste the code from the previous example into the window, then click &lt;strong&gt;File ▸ Save&lt;/strong&gt;. Enter &lt;code&gt;hello.py&lt;/code&gt; as the file name, and save it to your desktop. Then, you can click &lt;strong&gt;Run › Run Module&lt;/strong&gt; to run it.&lt;/p&gt;

&lt;p&gt;An alternative to IDLE for Python is &lt;strong&gt;Pycharm&lt;/strong&gt;, which is loved by many Python programmers. You can download the free community Pycharm from their &lt;a href="https://www.jetbrains.com/pycharm/download/"&gt;website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RMWaXNNW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzi7xx7k9k4g81r95k36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RMWaXNNW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzi7xx7k9k4g81r95k36.png" alt="Opening Pycharm shows a Tip of the Day message" width="880" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We prefer using &lt;strong&gt;Pycharm&lt;/strong&gt; because it provides a more user friendly environment. It really works like a charm! You can use it to create new programs and to run saved programs directly from within Pycharm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run your Python program from the Terminal
&lt;/h2&gt;

&lt;p&gt;We can also run our program from the Terminal by taking these steps:&lt;/p&gt;

&lt;h3&gt;
  
  
  For Windows
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;strong&gt;Command Prompt&lt;/strong&gt; from the Start Menu or Windows search.&lt;/li&gt;
&lt;li&gt;Enter &lt;code&gt;cd Desktop&lt;/code&gt; in the command window to change the directory to the folder containing our program.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;python hello.py&lt;/code&gt; to run the program.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  For Mac and Linux
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;strong&gt;Terminal&lt;/strong&gt; app from Applications.&lt;/li&gt;
&lt;li&gt;Enter &lt;code&gt;cd ~/Desktop&lt;/code&gt; in your terminal to change the directory to the folder containing the program.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;python3 hello.py&lt;/code&gt; to run it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With some luck, you should see the result of your Python program printed out!&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;p&gt;You just learned how to set up Python and how to start playing with it! Also: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to save your programs&lt;/li&gt;
&lt;li&gt;How to create variables to name values&lt;/li&gt;
&lt;li&gt;How to use parentheses to control the order of operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now would be a great time for a celebratory dance! 🎉&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>python</category>
      <category>101</category>
      <category>pycharm</category>
    </item>
    <item>
      <title>Setting up Python and virtualenv with pyenv</title>
      <dc:creator>HackerCulture</dc:creator>
      <pubDate>Sat, 15 May 2021 19:00:00 +0000</pubDate>
      <link>https://dev.to/hackerculture/setting-up-python-and-virtualenv-with-pyenv-3b21</link>
      <guid>https://dev.to/hackerculture/setting-up-python-and-virtualenv-with-pyenv-3b21</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8flxdoe4g19sgo8dqsus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8flxdoe4g19sgo8dqsus.png" alt="Setting up Python and virtualenv with pyenv" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this one, I’ll show you how to set up your local machine for python development so you can get started with python today. Let’s go!&lt;/p&gt;

&lt;p&gt;Python comes preinstalled in most operating systems by default. But sometimes you may want to upgrade to a newer version of Python or a new version of a library that you depend on which is not compatible with your current version of Python?&lt;/p&gt;

&lt;p&gt;If you upgrade your system version, you may introduce changes that are not backward compatible, and you may find yourself hours deep into the rabbit hole of upgrading your entire system.&lt;/p&gt;

&lt;p&gt;What we should do instead is use a library like Pyenv for installing multiple versions of Python and switching between them as needed.&lt;/p&gt;

&lt;p&gt;We'll also see how virtual environments can help us isolate changes between projects and how to keep project dependencies pinned to a specific version of Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ubuntu 20.x / WSL&lt;/li&gt;
&lt;li&gt;Internet connection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open up your terminal (if you’re using WSL, open up your Ubuntu terminal). First, we will update our package index and upgrade any installed packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter your password if prompted and wait for the terminal to finish.&lt;/p&gt;

&lt;p&gt;…&lt;/p&gt;

&lt;p&gt;Now, we will install all the python toolchain dependencies and build tools. Even though Ubuntu ships with python installed, we still need some other libraries to build and run python packages. This is the recommended list of dependencies for sane build environments, &lt;a href="https://github.com/pyenv/pyenv/wiki#suggested-build-environment" rel="noopener noreferrer"&gt;according to pyenv instructions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install -y make build-essential build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev python-dev python3-dev python3-pip python3-virtualenv python3-venv git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once that finishes, you should have all the necessary libraries installed. Now for the python specific part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pyenv
&lt;/h2&gt;

&lt;p&gt;The recommended way to manage your python dependencies and packages is to encapsulate your builds inside a python virtual environment. You might be wondering if you really need this, the answer (unless you want to spend most of your time in package versioning hell) is definitely yes.&lt;/p&gt;

&lt;p&gt;We’ll use &lt;strong&gt;pyenv&lt;/strong&gt; to manage python installations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/pyenv/pyenv.git ~/.pyenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to add these lines to your &lt;em&gt;.bashrc&lt;/em&gt; (or &lt;em&gt;.zshrc&lt;/em&gt; if you use &lt;strong&gt;zshell&lt;/strong&gt; )&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, you will need to reload your terminal session to apply the changes, or run &lt;code&gt;source ~/.bashrc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, let’s go ahead and make sure we have Python installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 --version
# Python 3.8.6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So my current version is 3.8.5 but there are newer versions out there. We can install them using &lt;strong&gt;pyenv&lt;/strong&gt; without messing with the default system version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv install 3.11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once that’s done, we can list all the installed versions with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv versions
* system (...)
  2.7.18
  3.8.13
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see some output like that, which tells me I have a system version, and others installed and available.&lt;/p&gt;

&lt;p&gt;The reason why this matters is that some legacy python code needs to run with &lt;em&gt;python2&lt;/em&gt; while newer code should be using &lt;em&gt;python3&lt;/em&gt; versions. Also, when a new version of python comes out, you can try it in a new project by installing it with &lt;strong&gt;pyenv&lt;/strong&gt; without having to worry about other legacy code not being able to run on the newer version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python virtual environments
&lt;/h2&gt;

&lt;p&gt;Let’s introduce virtual environments by looking at a problem you might encounter. You start working on some project which uses some pip package, like pandas. Without knowing about virtualenvs, you just do what one does to install pandas like &lt;em&gt;pip install pandas&lt;/em&gt; and just continue your work.&lt;/p&gt;

&lt;p&gt;All is good and well… except for the fact that now you installed a version of pandas in your system dependencies, which means some code you wrote months ago that depended on pandas too is now broken &lt;strong&gt;because pandas changed versions&lt;/strong&gt; and now it’s incompatible with your old code. That can be very messy.&lt;/p&gt;

&lt;p&gt;What we really want is to make sure whatever version of pandas we build our project with &lt;strong&gt;never changes behind the scenes&lt;/strong&gt; , so our code stays working even though pandas itself might change in the future. This is known as &lt;strong&gt;locking your dependencies&lt;/strong&gt; , and that’s exactly what virtualenvs are for.&lt;/p&gt;

&lt;p&gt;Let’s install virtual environments on top of &lt;strong&gt;pyenv&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv

echo 'eval "$(pyenv virtualenv-init -)"' &amp;gt;&amp;gt; ~/.profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I’ll show you how you can use virtual environments to isolate dependencies for a new project. I recommend creating a &lt;code&gt;src&lt;/code&gt; directory in your root dir and putting all your projects in there. Like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exec "$SHELL"

mkdir ~/src/new-project
cd ~/src/new-project

pyenv virtualenv 3.11 venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This just creates a new virtualenv which will use &lt;code&gt;python3.10-dev&lt;/code&gt; called &lt;code&gt;venv&lt;/code&gt;. You can use any version of python installed by &lt;strong&gt;pyenv&lt;/strong&gt; and any name you like, I just happen to use &lt;code&gt;venv&lt;/code&gt; for consistency.&lt;/p&gt;

&lt;p&gt;The last step is to actually activate the environment, so every command we run in this directory is isolated from the rest of our python installations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv activate venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you should see something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(venv) user@epyc02:~/src/new-project$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That first part on your path is telling us we are inside a virtual environment called &lt;code&gt;venv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;BTW you can exit the virtual environment with &lt;code&gt;pyenv deactivate&lt;/code&gt;, in case you want to switch between projects or install some packages outside your project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping up
&lt;/h3&gt;

&lt;p&gt;OK so now you are all set with python and you can install any dependencies in your project by running &lt;code&gt;pip install &amp;lt;package&amp;gt;&lt;/code&gt;. This will save your packages inside of your &lt;code&gt;venv&lt;/code&gt; directory and they will be local to your project. If you’re using &lt;strong&gt;git&lt;/strong&gt; it’s recommended to ignore everything under your &lt;code&gt;venv&lt;/code&gt; directory, so go ahead and add venv to your gitignore. &lt;em&gt;Note: if you called it something other than venv, substitute your environment’s name below instead of venv.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'venv' &amp;gt;&amp;gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That way if you deploy your code later or someone is pulling your code but has a different type of CPU when they install the packages they will actually get the right build for their particular environment.&lt;/p&gt;

&lt;p&gt;And that is all for our python environment setup. Go write some code!&lt;/p&gt;

</description>
      <category>python</category>
      <category>pyenv</category>
      <category>bash</category>
      <category>setup</category>
    </item>
  </channel>
</rss>
