Python tutorials

Staying secure by breaking Docker caching

When building Docker images, caching lets you speed up rebuilding images. But this has a downside: it can keep you from installing security updates from your base Linux distribution. If you cache the image layer that includes the security update… you’re not getting new security updates! There are a number of ways you can try to balance caching with getting security updates, with different tradeoffs. In this article we’ll cover: Caching by default, with recurring rebuild and redeploys. Deliberately breaking […]

Read more

Build a Maze Solver in Python Using Graphs

If you’re up for a little challenge and would like to take your programming skills to the next level, then you’ve come to the right place! In this hands-on tutorial, you’ll practice object-oriented programming, among several other good practices, while building a cool maze solver project in Python. From reading a maze from a binary file, to visualizing it using scalable vector graphics (SVG), to finding the shortest path from the entrance to the exit, you’ll go step by step […]

Read more

YAML: Python’s Missing Battery

Python is often marketed as a batteries-included language because it comes with almost everything you’d ever expect from a programming language. This statement is mostly true, as the standard library and the external modules cover a broad spectrum of programming needs. However, Python lacks built-in support for the YAML data format, commonly used for configuration and serialization. In this video course, you’ll learn how to work with YAML in Python using the available third-party libraries, with a focus on PyYAML. […]

Read more

How to Read Python Input as Integers

If you’ve ever coded an interactive text-based application in Python, then you’ve probably found that you need a reliable way of asking the user for integers as input. It’s not enough simply to display a prompt and then gather keystrokes. You must check that the user’s input really represents an integer. If it doesn’t, then your code must react appropriately—typically by repeating the prompt. In this tutorial, you’ll learn how to create a reusable utility function that’ll guarantee valid integer […]

Read more

Speeding up text processing in Python (is hard)

If you’re doing text or string manipulation in Python, what do you do if your code is too slow? Assuming your algorithm is reasonably efficient, the next step is to try faster alternatives to Python: a compiled extension. Unfortunately, this is harder than it seems. Some options don’t offer an easy path to optimizations, others are actually slower. To see this limitation in action, we’ll consider some alternatives: Pure Python, with the default Python interpreter. Cython. mypyc. Rust. Pure Python, […]

Read more
1 44 45 46 47 48 185