Python tutorials

Exploring Protocols in Python

In Python, a protocol specifies the methods and attributes that a class must implement to be considered of a given type. Protocols are important in Python’s type hint system, which allows for static type checking through external tools, such as mypy, Pyright, and Pyre. Before there were protocols, these tools could only check for nominal subtyping based on inheritance. There was no way to check for structural subtyping, which relies on the internal structure of classes. This limitation affected Python’s […]

Read more

Free-Threaded Python Unleashed and Other Python News for July 2025

Last month was a watershed moment for Python. Python 3.14 beta 3, released mid-June, isn’t just another pre-release. It’s the first build in which the long-awaited free-threaded or “no-GIL” variant is officially supported. That’s right: a no-GIL Python is finally taking shape. The interpreter isn’t the only thing making headlines, though. Below you’ll find a curated tour of the latest Python developments, broken down by area so you can zero in on your favorite topic. Core Python Development CPython’s core […]

Read more

330× faster: Four different ways to speed up your code

Note: The original version of this article was slightly different, e.g. with 500x speedup; I reworked it to make the argument clearer. If your Python code is slow and needs to be fast, there are many different approaches you can take, from parallelism to writing a compiled extension. But if you just stick to one approach, it’s easy to miss potential speedups, and end up with code that is much slower than it could be. To make sure you’re not […]

Read more

500× faster: Four different ways to speed up your code

If your Python code is slow and needs to be fast, there are many different approaches you can take, from parallelism to writing a compiled extension. But if you just stick to one approach, it’s easy to miss potential speedups, and end up with code that is much slower than it could be. To make sure you’re not forgetting potential sources of speed, it’s useful to think in terms of practices. Each practice: Speeds up your code in its own […]

Read more

Quiz: Python 3.14 Preview: Template Strings (T-Strings)

Interactive Quiz ⋅ 11 QuestionsBy Leodanis Pozo Ramos Share Evaluate your grasp of Python’s t-strings, which provide a structured and secure way to handle string templates. The quiz contains 11 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end of the quiz, you’ll receive a total score. The maximum score is 100%. Good luck! Related Resources

Read more

Python 3.14 Preview: Template Strings (T-Strings)

Python 3.14’s t-strings allow you to intercept and transform input values before assembling them into a final representation. Unlike f-strings, which produce a str object, t-strings resolve to a Template instance, allowing you to safely process and customize dynamic content. One of the key benefits of t-strings is their ability to help prevent security vulnerabilities like SQL injection and XSS attacks. They’re also valuable in other fields that rely on string templates, such as structured logging. By the end of […]

Read more

Implementing the Factory Method Pattern in Python

This video course explores the Factory Method design pattern and its implementation in Python. Design patterns became a popular topic in late 90s after the so-called Gang of Four (GoF: Gamma, Helm, Johson, and Vlissides) published their book Design Patterns: Elements of Reusable Object-Oriented Software. The book describes design patterns as a core design solution to reoccurring problems in software and classifies each design pattern into categories according to the nature of the problem. Each pattern is given a name, […]

Read more

Quiz: Use TorchAudio to Prepare Audio Data for Deep Learning

Interactive Quiz ⋅ 10 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of audio fundamentals and how to Use TorchAudio to Prepare Audio Data for Deep Learning. You’ll revisit fundamental terminology and how to: Install and import TorchAudio Load audio waveform datasets Apply signal transforms Work through these questions to check your knowledge about building audio workflows for machine learning in Python. The quiz contains 10 questions and there is no time limit. You’ll get 1 point […]

Read more

Use TorchAudio to Prepare Audio Data for Deep Learning

Ever wondered how machine learning models process audio data? How do you handle different audio lengths, convert sound frequencies into learnable patterns, and make sure your model is robust? This tutorial will show you how to handle audio data using TorchAudio, a PyTorch-based toolkit. You’ll work with real speech data to learn essential techniques like converting waveforms to spectrograms, standardizing audio lengths, and adding controlled noise to build machine and deep learning models. Dive into the tutorial to explore these […]

Read more

Quiz: The Python print() Function

Interactive Quiz ⋅ 12 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of Your Guide to the Python print() Function. The print() function outputs objects to the console or a specified file-like stream. You’ll practice: Printing multiple values with custom separators Changing the end-of-line character Redirecting output using the file parameter Forcing immediate output with the flush parameter Work through these questions to reinforce your knowledge of print()’s parameters and best practices for clear, formatted I/O. The […]

Read more
1 2 3 194