Python tutorials

Faster, more memory-efficient Python JSON parsing with msgspec

If you need to process a large JSON file in Python, you want: Make sure you don’t use too much memory, so you don’t crash half-way through. Parse it as quickly as possible. Ideally, make sure the data is actually valid up-front, with the right structure, so you don’t blow up half-way through your analysis. You can put together solutions with multiple libraries, of course. Or, you can use msgspec a new library that offers schemas, fast parsing, and some […]

Read more

pandas GroupBy: Your Guide to Grouping Data in Python

Whether you’ve just started working with pandas and want to master one of its core capabilities, or you’re looking to fill in some gaps in your understanding about .groupby(), this tutorial will help you to break down and visualize a pandas GroupBy operation from start to finish. This tutorial is meant to complement the official pandas documentation and the pandas Cookbook, where you’ll see self-contained, bite-sized examples. Here, however, you’ll focus on three more involved walkthroughs that use real-world datasets. […]

Read more

Deploying a Flask Application Using Heroku

In this video course, you’ll create a Python Flask example application and deploy it using Heroku, making it publicly available on the web. Heroku removes much of the infrastructure burden related to building and running web applications, allowing you to focus on creating an awesome app. Besides deploying the app, you’ll use Git to track changes to the code, and you’ll also configure a deployment workflow with different environments for staging and production. Using this setup, you’ll be able to […]

Read more

Python News: What’s New From April 2022

April 2022 saw the return of the PyCon US conference in person in Salt Lake City. During the conference, Python developers met for the annual Language Summit, and Anaconda announced PyScript, a way to write Python directly inside HTML. Earlier in the month, the Python Software Foundation (PSF) welcomed its new executive director. Read on to dive into the biggest Python news from the past month! PyScript: Python in Your Browser During his keynote at PyCon US, Anaconda CEO Peter […]

Read more

Top Python Game Engines

Like many people, maybe you wanted to write video games when you first learned to code. But were those games like the games you played? Maybe there was no Python when you started, no Python games available for you to study, and no game engines to speak of. With no real guidance or framework to assist you, the advanced graphics and sound that you experienced in other games may have remained out of reach. Now, there’s Python, and a host […]

Read more

Testing Your Code With pytest

Testing your code brings a wide variety of benefits. It increases your confidence that the code behaves as you expect and ensures that changes to your code won’t cause regressions. Writing and maintaining tests is hard work, so you should leverage all the tools at your disposal to make it as painless as possible. pytest is one of the best tools you can use to boost your testing productivity. In this video course, you’ll learn: What benefits pytest offers How […]

Read more

Python’s min() and max(): Find Smallest and Largest Values

Python’s built-in min() and max() functions come in handy when you need to find the smallest and largest values in an iterable or in a series of regular arguments. Even though these might seem like fairly basic computations, they turn out to have many interesting use cases in real-world programing. You’ll try out some of those use cases here. In this tutorial, you’ll learn how to: Use Python’s min() and max() to find smallest and largest values in your data […]

Read more

Real Python at PyCon US 2022

PyCon US is back as an in-person conference. PyCon US 2022 is happening in Salt Lake City April 29 to May 1, and Real Python is there as well. Come join us at our booth and at the open space on Saturday. In this article, you’ll learn where you can find Real Python at PyCon in Salt Lake City, and get to know what some of our team members are excited about at the conference. Meet Real Python at PyCon […]

Read more

When Python can’t thread: a deep-dive into the GIL’s impact

Most computers these days come with multiple cores, allowing multiple threads to run computations in parallel. And even without multiple cores, you can have concurrency, for example one thread waiting on disk while another runs code on the CPU. The ability to use parallelism can be critical to scaling your application—or making your data processing finish faster. Unfortunately, in many cases Python can only run one thread at a time, due to what’s know as the Global Interpreter Lock (“GIL”). […]

Read more

Why Is It Important to Close Files in Python?

At some point in your Python coding journey, you learn that you should use a context manager to open files. Python context managers make it easy to close your files once you’re done with them: with open(“hello.txt”, mode=”w”) as file: file.write(“Hello, World!”) The with statement initiates a context manager. In this example, the context manager opens the file hello.txt and manages the file resource as long as the context is active. In general, all the code in the indented block […]

Read more
1 104 105 106 107 108 193