skip to navigation
skip to content

Planet Python

Last update: March 19, 2025 07:43 AM UTC

March 18, 2025


Python Morsels

Refactoring long boolean expressions

You can improve the readability of long boolean expressions by splitting your code, naming sub-expressions, or rewriting your Boolean logic.

Table of contents

  1. Breaking up long expressions
  2. Naming sub-expressions with variables
  3. Naming operations with functions
  4. Using De Morgan's Law
  5. Make your Boolean expression more readable

Breaking up long expressions

Here's a fairly long Boolean expression:

from datetime import datetime

event = {"name": "Intro", "date": datetime(2030, 3, 6), "full": False}
user = {"name": "jill", "verified": True, "role": "admin", "perms": ["edit"]}

if user["verified"] and event["date"] > datetime.now() and not event["full"]:
    print("Here's the event signup form...")

We could make this a little bit more readable by splitting our code up over multiple lines (thanks to implicit line continuations), with each line starting with a Boolean operator:

from datetime import datetime

event = {"name": "Intro", "date": datetime(2030, 3, 6), "full": False}
user = {"name": "jill", "verified": True, "role": "admin", "perms": ["edit"]}

if (user["verified"]
        and event["date"] > datetime.now()
        and not event["full"]):
    print("Here's the event signup form...")

Or we could put the Boolean operators at the end of each line, if we prefer:

from datetime import datetime

event = {"name": "Intro", "date": datetime(2030, 3, 6), "full": False}
user = {"name": "jill", "verified": True, "role": "admin", "perms": ["edit"]}

if (user["verified"] and
        event["date"] > datetime.now() and
        not event["full"]):
    print("Here's the event signup form...")

But PEP8 (the official Python style guide) recommends putting binary operators (operators that go in between two values, like and and or) at the beginning of each line, for the sake of readability.

That way it's a little bit easier to see at a glance how we're joining our sub-expressions together:

from datetime import datetime

event = {"name": "Intro", "date": datetime(2030, 3, 6), "full": False}
user = {"name": "jill", "verified": True, "role": "admin", "perms": ["edit"]}

if (user["verified"]
        and event["date"] > datetime.now()
        and not event["full"]):
    print("Here's the event signup form...")

Naming sub-expressions with variables

We could also try using …

Read the full article: https://www.pythonmorsels.com/refactoring-boolean-expressions/

March 18, 2025 10:40 PM UTC


PyCoder’s Weekly

Issue #673: Textual UIs, Tail-Call Performance, Bidirectional Generators, and More (March 18, 2025)

#673 – MARCH 18, 2025
View in Browser »

The PyCoder’s Weekly Logo


Python Textual: Build Beautiful UIs in the Terminal

Textual is a Python library for building text-based user interfaces (TUIs) that support rich text, advanced layouts, and event-driven interactivity in the terminal. This tutorial showcases some of the ways you can design an appealing and engaging UI using Textual.
REAL PYTHON

Quiz: Python Textual: Build Beautiful UIs in the Terminal

REAL PYTHON

Performance of the Python 3.14 Tail-Call Interpreter

Prior reports of 10% speed-up from the tail-call interpreter coming in Python 3.14 may be overstated. This article breaks down where that number came from and what the reality may be.
NELSON ELHAGE

Postman AI Agent Builder Is Here: The Quickest Way to Build AI Agents. Start Building

alt

Postman AI Agent Builder is a suite of solutions that accelerates agent development. With centralized access to the latest LLMs and APIs from over 18,000 companies, plus no-code workflows, you can quickly connect critical tools and build multi-step agents — all without writing a single line of code →
POSTMAN sponsor

Binary Search as a Bidirectional Generator

Python generators support a .send() method, allowing you to receive data within the generator itself. This post talks about how to use this to implement a binary search algorithm.
RODRIGO GIRÃO SERRÃO

PSF Distinguished Service Award for Thomas Wouters

PYTHON SOFTWARE FOUNDATION

PyOhio July 26-27, Call for Papers

PRETALX.COM • Shared by Keith Murray

Articles & Tutorials

Providing Multiple Constructors in Your Python Classes

In this step-by-step tutorial, you’ll learn how to provide multiple constructors in your Python classes. To this end, you’ll learn different techniques, such as checking argument types, using default argument values, writing class methods, and implementing single-dispatch methods.
REAL PYTHON

Getting to Know Duck Typing in Python

In this video course, you’ll learn about duck typing in Python—a type system based on an object’s behavior rather than inheritance. By taking advantage of duck typing, you can create flexible and decoupled sets of Python classes that work together or independently.
REAL PYTHON course

Detect and Localize Anomalies With Intel AI, Powered by OpenVINO

Discover Anomalib, a library of ready-to-use algorithms for efficient anomaly detection. Optimized to run locally and open source, it’s designed to help you spot the odd one out. Get the code on GitHub.
INTEL CORPORATION sponsor

Satellogic’s Open Satellite Feed

This post explores the “Satellogic EarthView” data feed, starting with determining where the satellites are, and moving to the corresponding ground imagery. The post uses a combination of Python and DuckDB to achieve its objectives.
MARK LITWINTSCHIK

The Hierarchy of Controls

This article, subtitled “how to stop devs from dropping prod” takes an idea from mechanical engineering used to ensure safety around machinery and brings it to the software world to prevent accidental destruction of data.
HILLEL WAYNE

Build a Dice-Rolling Application With Python

In this step-by-step project, you’ll build a dice-rolling simulator app with a minimal text-based user interface using Python. The app will simulate the rolling of up to six dice. Each individual die will have six sides.
REAL PYTHON

“Rules” That Terminal Programs Follow

The conventions that most terminal programs follow mean that you can more easily know how to control them. Julia’s post talks about “rules” that terminal programs tend to follow, and so should yours.
JULIA EVANS

Sustainable Coding: How Do I Apply It as a Cloud Engineer?

Choices we make as programmers effect the amount of processing power required in production and ultimately that has a carbon cost. Ed’s post talks about how he thinks about this larger picture.
ED CREWE

Font Ligatures for Your Code Editor and Terminal

A font ligature combines two characters into a single rendering, allowing “>=” to look like a single symbol. This article shows you how you can do this with common terminals and editors.
MIGUEL GRINBERG

Python Discord 2024 Survey Report

The Python Discord server does an annual survey. This page is a giant notebook showing the results for the last four years along with the code that generates the corresponding graphs.
PYTHON DISCORD

The Boolean Trap

Often when using a Boolean in an API you are making the API harder to understand. This post explains why most of the time you should use enums instead.
ENGINEER’S CODEX

Faster Branch Coverage Measurement

After nearly two years, Ned thinks this is finally ready: coverage.py can use sys.monitoring to more efficiently measure branch coverage.
NED BATCHELDER

Projects & Code

djoser: REST Implementation of Django Authentication System

GITHUB.COM/SUNSCRAPERS

html5lib-python: Parse HTML Documents and Fragments

GITHUB.COM/HTML5LIB

stumpy: Modern Time Series Analysis

GITHUB.COM/TDAMERITRADE

poetry-dockerize-plugin: Generate a Docker Image From Poetry

GITHUB.COM/NICOLOBOSCHI

opendbc: A Python API for Your Car

GITHUB.COM/COMMAAI

Events

Weekly Real Python Office Hours Q&A (Virtual)

March 19, 2025
REALPYTHON.COM

Creating Python Communities and Outreach

March 20 to March 21, 2025
NOKIDBEHIND.ORG

PyData Bristol Meetup

March 20, 2025
MEETUP.COM

PyLadies Dublin

March 20, 2025
PYLADIES.COM

PyCamp Argentina 2025

March 21 to March 25, 2025
PYAR.DISCOURSE.GROUP


Happy Pythoning!
This was PyCoder’s Weekly Issue #673.
View in Browser »

alt

[ Subscribe to 🐍 PyCoder’s Weekly 💌 – Get the best Python news, articles, and tutorials delivered to your inbox once a week >> Click here to learn more ]

March 18, 2025 07:30 PM UTC


PyBites

FastAPI Deployment Made Easy with Docker and Fly.io

For the PDM program I worked on a FastAPI project to track books using the Google Book API and also provide AI powered recommendations using Marvin AI. As the project came closer to deployment, I knew that I wanted to try out containerization for a reliable and repeatable way to deploy. I chose Docker due to its widespread use, open-source nature, and consistent behavior across environments.If you’re new to Docker or looking for a straightforward guide to deploying a FastAPI app with Docker and Fly.io, this post is for you.


FastAPI Set Up for Docker

Before deploying the app, we need to containerize it using Docker. To do this we need to start with creating a Dockerfile, which defines how the project will be packaged and run inside of the container. 

Project Structure

A clean project structure will improve the build efficiency, dependency management, security, and easier maintainability and readability. Here is the structure I used for my FastAPI project:

$ tree
.
├── Dockerfile
├── LICENSE
├── Procfile
├── README.md
├── alembic.ini
├── app.py
├── auth.py
├── config.py
├── db.py
├── docker-compose.yml
├── fly.toml
├── heroku.yml
├── main.py
├── migrations
│   ├── README
│   ├── env.py
│   ├── script.py.mako
│   └── versions
│       ├── 2ab73586da75_initial_migration.py
│       ├── 2e3f7780d24b_update_user_book_status_models.py
│       ├── 56b69f39cacf_add_book_index.py
│       └── bcc627763cfc_add_rate_limit_table.py
├── models.py
├── pages
│   ├── ai_recommendations.py
│   ├── login.py
│   ├── saved_books.py
│   └── signup.py
├── pyproject.toml
├── requirements.txt
├── screenshots
│   ├── ai_recommendation.png
│   ├── book_search.png
│   └── saved_books.png
├── services
│   ├── __init__.py
│   ├── google_books.py
│   └── marvin_ai.py
├── styles
│   └── global.css
├── tests
│   ├── __init__.py
│   ├── conftest.py
│   └── test_main.py
└── wait-for-it.sh

8 directories, 38 files

Writing the Dockerfile:

The Dockerfile is the key component that tells Docker how to set up the environment for the FastAPI app. 

# Use the full Python image instead of slim to avoid missing system dependencies
FROM python:3.11

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
   UV_NO_INDEX=1 \
   DEBIAN_FRONTEND=noninteractive

# Set the working directory inside the container
WORKDIR /app

# Install uv globally first
RUN pip install --no-cache-dir uv

# Install dependencies globally (avoiding virtual env issues)
COPY pyproject.toml ./
RUN uv pip install --system -r pyproject.toml

# Copy the rest of the application code
COPY . .

# Expose the FastAPI default port
EXPOSE 8000

# Copy wait-for-it.sh into the container (if needed)
COPY wait-for-it.sh /usr/local/bin/wait-for-it
RUN chmod +x /usr/local/bin/wait-for-it

# Run the application
CMD ["sh", "-c", "/usr/local/bin/wait-for-it db:5432 -- uv run uvicorn main:app --host 0.0.0.0 --port 8000"]

I initially tried using python: 3.11-slim to keep the container lightweight but ran into some missing system dependencies. After researching my issues, I decided to go with the full image, which solved the problems I was having. Optimizing the image is a future goal of the project.

To ensure the database is ready before starting the FastAPI app, we use a small script called wait-for-it.sh. This utility blocks the container’s startup until a specified host and port (in our case, the database) becomes available. It’s a lightweight, reliable way to avoid race conditions where the app tries to connect to the database before it’s fully up—something that can often happen in Dockerized deployments where services start concurrently.

Creating a .dockerignore File

After the Dockerfile is done, we need to set up a .dockerignore file. This is used to keep the Docker image  small and clean. It works just like a .gitignore file, as we want to exclude files that aren’t relevant to the container plus exclude any secret keys, environment variables, etc. 

__pycache__/
*.pyc
*.pyo
*.sqlite3
.env
migrations/**/__pycache__/
tests/__pycache__/
.vscode/
.idea/
*.swp
*.swo
.DS_Store

With the Dockerfile and Dockerignore files ready, we are set to build the image locally!

Building and Running the Docker Container Locally

Now we need to build the container and test the FastAPI project before deploying it. This will ensure that the project will run smoothly in a Dockerized environment. 

Building the Image

First step is to build the Docker image. A Docker image is a blueprint for containers. This image will package the code, dependencies, and environment configurations. To build the image, we need to run the below command in the root of the project (where the Dockerfile is located):

docker build -t read-radar-api .

Running the Container

Once the image is successfully built we can run the container. Use the below command to start:

docker run -p 8000:8000 read-radar-api

After running this command, logs from Uvicorn should be available. This means that your FastAPI app is running inside the container!

You can test running the app by going to http://localhost:8000/docs in your browser. If working correctly, you’ll see the Swagger UI for the FastAPI interactive docs. 

Using Docker Compose for PostgreSQL

For my project I used PostgreSQL for my database and we will also need to get that set up before deploying to Fly.io. 

Docker Compose makes a PostgreSQL database simple to set up. Just create a docker-compose.yml file in the root of the project directory:

version: "3.8"
services:
 db:
   image: postgres:15
   container_name: postgres_db
   restart: always
   environment:
     POSTGRES_USER: ${POSTGRES_USER}
     POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
     POSTGRES_DB: ${POSTGRES_DB}
   volumes:
     - postgres_data:/var/lib/postgresql/data
   ports:
     - "5432:5432"
 web:
   build: .
   container_name: fastapi_app
   depends_on:
     - db
   environment:
     DATABASE_URL: ${DATABASE_URL}
   ports:
     - "8000:8000"
   volumes:
     - .:/app
   command: ["/usr/local/bin/wait-for-it", "db:5432", "--", "uv", "run", "python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
volumes:
 postgres_data:

Once that file is set up, we can have Docker spin up both services using:

docker-compose up -d

This will have both our FastAPI running at the localhost and PostgreSQL will be available at  postgresql://myuser:mypassword@localhost:5432/mydatabase (change the user, password, and database to match yours)

Once both are running successfully, we are ready to move onto deploying to Fly.io.


Deploying to Fly.io

Why Fly.io?

Containerization is great, but without deploying it to the cloud, others won’t be able to access the app. There are a variety of options to deploy like Fly.io or Heroku. I chose Fly.io because I was having issues with Heroku that required me to contact support. But using Fly.io was pretty simple, supporting Docker containers out of the box, and is relatively cheap with them changing to a pay-as-you-go system. You can also set up credits, so that you don’t run the risk of getting a super high bill. 

Setting Up Fly.io

The CLI is a tool that is needed to deploy and it can be downloaded with the following command:

curl -L https://fly.io/install.sh | sh

Then just restart the terminal and login. It will guide you through creating an account if you don’t have one yet:

flyctl auth login

Once logged in, we can initialize the Fly.io app. Once in your FastAPI project folder, run the following command:

flyctl launch

This will detect the Dockerfile and create a fly.toml configuration file. 

Setting Up PostgreSQL on Fly.io

Fly.io provides a managed PostgreSQL service, which makes the choice of database pretty easy if you are planning on using Fly.io like I did. 

To set up the database just use the following command:

flyctl postgres create

Just like initializing the app, it’ll ask you for a region for the database. Fly.io will then provision a PostgreSQL database and then provide a database connection URL. It’s super important to save this URL!

Now that the FastAPI app and PostgreSQL database are set up in Fly.io, we need to connect them! It’s a simple command that will link the PostgreSQL instance to the FastAPI app and then store the database connection URL as a Fly.io secret. Run the following command:

flyctl postgres attach --app read-radar-api

Deploying the App

Now we can deploy the FastAPI container to Fly.io! Just do the following command:

flyctl deploy

This will build the Docker image, push it to Fly.io’s container registry, and deploy it in the chosen region. Once it successfully completes, Fly.io will provide the public URL for the API:

https://read-radar-api.fly.dev/docs

Applying Database Migrations

Once deployed, we will need to apply database migrations in the deployed container. I’ve used Alembic for this and it makes it a simple process. First, we need to open an SSH session of the Fly app:

flyctl ssh console

Then run:

alembic upgrade head

This will apply the database migrations to the deployed container.

Later I learned that Fly supports release commands that run before a new deployment becomes active, so you can automate this step by adding this to your fly.toml file:

[deploy]
  release_command = "alembic upgrade head"

Debugging & Testing

A few simple commands to check on how the app is working on Fly.io.

To check the logs for any error just run:

flyctl logs

To check the app’s status:

flyctl status

And if the app crashes, you can redeploy by doing:

flyctl deploy –remote-only


Final Thoughts

WIth that, deploying the Docker container to Fly.io is complete! The next step would be to integrate it with a frontend. For my project I used Streamlit and it was a fairly easy process since all of the logic was done on the FastAPI backend. Other future enhancements would be CI/CD for automated deployments, and using Fly.io’s auto-scaling features. 

This project was a great introduction to Docker and Fly.io! The combination of clear documentation, guidance from my coach, and help from ChatGPT got me through the tricky parts. As we enter this new age of AI, it’s powerful to ask specific questions to AI — just be sure to understand and apply its suggestions wisely. That said, having a coach to provide tailored feedback and accountability made all the difference in truly grasping the concepts.

I hope this guide will help others implement Docker and Fly.io!

March 18, 2025 04:14 PM UTC


Real Python

Using Structural Pattern Matching in Python

Structural pattern matching is a powerful control flow construct invented decades ago that’s traditionally used by compiled languages, especially within the functional programming paradigm.

Most mainstream programming languages have since adopted some form of pattern matching, which offers concise and readable syntax while promoting a declarative code style. Although Python was late to join the party, it introduced structural pattern matching in the 3.10 release.

In this video course, you’ll:


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

March 18, 2025 02:00 PM UTC


PyCon

PyCon US 2025 - Travel Grants Transparency Blog Post

Providing travel grants to community members for PyCon US and witnessing both their growth and contributions to the event is one of the most fulfilling aspects of our work at the PSF, and every year, we only wish we could award more!

PyCon US 2025 received 952 travel grant applications from 87 countries totaling almost $1.7M. We dislike using the phrase “record-breaking” every year, but it’s true! Again, the number and amount requested have broken our 2024 record. The total dollar amount requested was more than six times the available budget. For 2025, the total PyCon US revenue is budgeted at $2.3M and supports conference costs of $2.5M, including $266K in travel grant funds. The Travel Grant Team offered 272 travel grants and 33 ticket-only grants, amounting to $384K, or about 23%, of travel grant requests received.

The PSF is committed to financial transparency, and in line with that commitment, we are happy to share more about how our PyCon US 2025 travel grant process works. 

Travel Grant Funding

PyCon US travel grants are funded from various sources including PyCon US ticket sales and sponsorships, the Python Core Devs, the Packaging Work Group, the PSF, and generous contributions from PyLadies. In addition, we already have a direct sponsorship for 2025 travel grants from OpenEDG Python Institute!

Inflation in event costs, continued economic risk from the tech sector, and global market swings mean that many corporations are funding less travel for both speakers and attendees. PyCon US has received increased travel grant requests over the past two years. We are working with a limited budget and can only accommodate a portion of those who applied.

Travel Grant Award Philosophy

PyCon US Travel Grants are designed to further our non-profit mission of promoting, protecting, and advancing the Python programming language while supporting the growth of a diverse and global community of Python developers. Our goal is to create an event that mirrors this diversity, unites individuals who will gain valuable experiences and bring those benefits back to their communities, and delivers an engaging and impactful experience from the first tutorial to the final sprint.

To achieve these goals, we allocate part of our budget to fund our incredible lineup of speakers, and this year, to reduce costs, we limited travel grants to up to 2 speakers per talk. We prioritized factors such as global representation, welcoming first-time PyCon US attendees, supporting folks looking for new job opportunities, and inviting students, educators, and community organizers from around the world. Despite our best efforts, the bittersweet reality remains that we couldn't award grants to everyone who applied.

Although we are a US-based conference and non-profit organization, PyCon US strives to bring folks from around the world. In fact, about 75% of travel grant funds were offered to non-US Pythonistas covering 58 countries!


Percentage of Travel Grants Awarded by Continent


The PyCon US Travel Grant Team takes a personalized approach to the awards process, and each application is reviewed multiple times (by humans!). The team continues to be impressed with the true community spirit of the Python community! All travel grant awards for PyCon US 2024 were used by awardees.

Award Outcome

As of the acceptance deadline of March 11th, 2025, 226 full travel and 28 ticket-only grants were accepted by grantees. 9 full travel and 2 ticket-only grants were declined, and a handful of grants expired.

We do not have additional funds to award because the Travel Grant Team intentionally over-awards grants; for reference, our budget was $266K, and we offered $384K. Based on several years of historical travel grant offers, acceptance, and use trends, the team has found that many folks aren’t able to use the travel grant due to changes in personal circumstances, illness, changes in work or education commitments, as well as issues securing a US visa.

You can find more information on the PyCon US Travel Grants FAQ. If you have feedback or questions about our process, please contact us at pycon-aid@python.org.

Sincerely,

The PyCon US 2025 Travel Grant Team

 

p.s. As a final note, we’d love to continue expanding our travel grant program in the future. If you’d like to help do that, a great way is to encourage your employer or other companies you are connected with to sponsor the PSF or to let them know you notice and appreciate it if they are already a sponsor.

March 18, 2025 09:53 AM UTC


EuroPython

Keynote & Ticket Sales Announcement!

Hello, Pythonistas! 🐍 Welcome back to our cosy corner of community & code!

It&aposs absolutely fantastic to have you here again, especially as we countdown the days until our reunion in Prague! 🎉 Quite a few things have happened since our last catch-up so let’s dive right into it!

📣 Programme

We&aposre super excited to announce Savannah Ostrowski as a keynote speaker for EuroPython 2025! 🐍✨

Savannah Ostrowski is a Python Core Developer and a product lead for Python Developer Experience and Notebooks at Snowflake. She helps maintain the argparse module in the Python standard library and the new JIT compiler introduced in Python 3.13. A self-taught developer with a background in geospatial computing, she has built a career at the intersection of developer tools and open-source software.

Before Snowflake, Savannah led a product for Docker’s runtime, working on foundational technology for the container ecosystem, including Docker Engine (moby/moby) and Docker CLI. She previously worked at Microsoft on the Azure Developer CLI and was the product manager for the Pylance language server.

If you&aposve seen any of her previous talks, you know she&aposs a fantastic speaker with practical insights to share and if you haven&apost checked out her presentations yet, you&aposre in for a treat!

Join us at EuroPython 2025 to hear Savannah&aposs unique insights and vision for Python&aposs future. It&aposs a session you won&apost want to miss!

alt

🎟️ Ticket Sales

Get ready, Python enthusiasts! EuroPython 2025 tickets will start this week! Tutorial spaces are limited, so if you plan to purchase a combined or tutorials-only ticket, we recommend registering soon.

Prices stay the same as last year, and for more detailed announcement follow us on social media for all the latest updates:

💰 Sponsorship

If you&aposre passionate about supporting EuroPython and helping us make the event accessible to all, consider becoming a sponsor or asking your employer to join us in this effort.

By sponsoring EuroPython, you’re not just backing an event – you&aposre gaining highly targeted visibility and the chance to present your company or personal brand to one of the largest and most diverse Python communities in Europe and beyond!

We offer a range of sponsorship tiers, some with limited slots available. Along with our main packages, there are optional add-ons and optional extras.

🐦 We have an Early Bird 10% discount for companies that sign up by March 28th.🐦

👉 More information at: https://ep2025.europython.eu/sponsorship/sponsor/ 

👉 Contact us at sponsors@europython.eu

💶 Financial Aid

We are also pleased to announce our financial aid, sponsored by the EuroPython Society. The goal is to make the conference open to everyone, including those in need of financial assistance.

You can apply for three different types of grants:

Submissions for the first round of our financial aid programme are open until April 4th 2024. More information on https://ep2025.europython.eu/finaid/

 🎥 YouTube

Our YouTube channel has hit 4.2M+ views! Ever wondered which talks are the most popular?

Here are the top 10 most-watched talks on our channel:

 A huge thank you to our amazing speakers who share their knowledge with the community!

📺 Watch them here: https://www.youtube.com/channel/UC98CzaYuFNAA_gOINFB0e4Q

EuroPython Conference
The official YouTube Channel of the EuroPython conferences. Current edition: EuroPython 2025. EuroPython is the official European conference for the Python programming language. Copyright © 2004-2025, EuroPython Speakers, EuroPython Society, Sweden and the Local Organisers of the EuroPython confer…
alt

📊 EuroPython Society Board Report 

The EuroPython conference wouldn’t be what it is without the incredible volunteers who make it all happen. 💞 Behind the scenes, there’s also the EuroPython Society—a volunteer-led non-profit that manages the fiscal and legal aspects of running the conference, oversees its organization, and works on a few smaller projects like the grants programme. To keep everyone in the loop and promote transparency, the Board is sharing regular updates on what we’re working on.

The February board report is ready: https://www.europython-society.org/board-report-for-february/

📣 Community Outreach

Beyond merely attending Python gatherings, EuroPython takes an active role in fostering their success. We proudly serve as community sponsors, providing support to regional Python meetups. We are committed to nurturing the broader ecosystem and bolstering Python conferences throughout Europe. 🐍💙

Brno Python Pizza

EuroPython proudly sponsored Brno Python Pizza and had some of our members join the event in person. Special thanks to Jake Balaš for delivering an excellent lightning talk about EuroPython! Thank you to the organizers for putting together such an excellent event, and to all the attendees who made it so special.

altaltalt

💞Upcoming Events in the Python Community

🐣 See You All Next Month

Before saying goodbye, thank you so much for reading. We can’t wait to reunite with all you amazing people in beautiful Prague again. It truly is time to make new Python memories together!

In the meantime, follow us on social media: 

With so much joy and excitement,

EuroPython 2025 Team 🤗

March 18, 2025 07:00 AM UTC

March 17, 2025


Lucas Cimon

A review of HTML linters

... and how to use them in CI pipelines.

Comparing W3C v.Nu HTML checke, html-tidy, htmlhint, html-validate, LintHTML and html-eslint.


Permalink

March 17, 2025 11:49 PM UTC


EuroPython Society

Board Report for February 2025

In February, our top priority was event logistics and organizational planning. We worked closely with our event manager, Anežka, on important aspects such as the venue, catering, and other logistics. We&aposre happy to announce that the contract with the venue has been signed!

Another priority was budget planning. Our funding comes from ticket sales and sponsors. We reviewed fixed costs and discussed our strategy for this year. We want to keep the event as affordable as possible to allow more people to attend while also attracting sponsors. At the same time, we need to make sure that the event breaks even and remains financially sustainable in the long term. We also worked on defining sponsorship packages.

The third priority was onboarding the remaining co-leads and teams. Some board members are still involved in specific teams to support new co-leads and other newcomers. We&aposre making sure that everyone has the support and tools they need to contribute.

Individual reports:

Artur

Mia

Aris

Ege

Shekhar

Cyril

Anders

March 17, 2025 10:30 PM UTC


Real Python

Python's Instance, Class, and Static Methods Demystified

Instance, class, and static methods each serve a distinct role in Python, and knowing when to use one over another is key to writing clean, maintainable code. Instance methods operate on individual objects using self, while class methods use cls to access class-level data. Static methods, on the other hand, provide organizational structure without relying on class or instance state.

When you understand the differences between these three method types, you’ll be in a better spot to know when to write an instance method, class method, or a static method. Ultimately, this’ll help you design better maintainable object-oriented Python code.

By the end of this tutorial, you’ll understand that:

  • Instance methods access the state of a specific object through the self parameter.
  • You create class methods with the @classmethod decorator and use them for operations that involve class-level data.
  • You use static methods for utility functionality that doesn’t need class or instance data, and you create them with the @staticmethod decorator.
  • Using class methods and static methods in your classes can improve class design and code maintainability.

Keep reading to see all three method types in action. You’ll even bake some digital pizza while working on a real-world example with all three method types in a Pizza class. If you develop an intuitive understanding for their differences, you’ll be able to write object-oriented Python code that communicates its intent more clearly and is easier to maintain in the long run.

Get Your Code: Click here to download the free sample code you’ll use to learn about instance, class, and static methods in Python.

Take the Quiz: Test your knowledge with our interactive “Python's Instance, Class, and Static Methods Demystified” quiz. You’ll receive a score upon completion to help you track your learning progress:


Interactive Quiz

Python's Instance, Class, and Static Methods Demystified

In this quiz, you'll test your understanding of instance, class, and static methods in Python. By working through this quiz, you'll revisit the differences between these methods and how to use them effectively in your Python code.

Compare Instance Methods vs Class Methods vs Static Methods

If you’re here for a quick reminder of how the three method types differ from one another, then consider the following overview that compares them:

  • Instance methods use a self parameter pointing to an instance of the class. They can access and modify instance state through self and class state through self.__class__. These are the most common methods in Python classes.

  • Class methods use a cls parameter pointing to the class itself. They can modify class-level state through cls, but they can’t modify individual instance state.

  • Static methods don’t take self or cls parameters. They can’t modify instance or class state directly, and you’ll mainly use them for organizational purposes and namespacing.

If you need to revisit information quickly, there’s nothing quite like a table. So here are the most important aspects of the three different types of methods in Python classes summed up in a table:

Type Decorator Parameter Instance Access Class Access Use Case
Instance None needed self Operations on individual instances.
Class @classmethod cls Factory methods, alternative constructors, or any method that deals with class-level data.
Static @staticmethod No self or cls Utility methods that don’t need instance or class data.

That’s enough super-condensed, repetitive reference information! If you want to know what all of this means in practice, and you like to learn by running code snippets and reasoning about them, then keep on reading.

Next, you’ll explore the differences between instance, class, and static methods in a somewhat abstract code example. Abstract you say? Don’t worry—it involves runnable code, and it’s there to set the stage for a more practical example later on.

Gain Insight Through an Abstract Example

To get warmed up, you’ll write a small Python file called demo.py with a bare-bones Python class that contains stripped-down examples of all three method types:

Python demo.py
class DemoClass:
    def instance_method(self):
        return ("instance method called", self)

    @classmethod
    def class_method(cls):
        return ("class method called", cls)

    @staticmethod
    def static_method()
        return ("static method called",)
Copied!

Inside demo.py, you create DemoClass—a descriptively named custom class with the sole purpose of demoing the differences between instance methods, class methods, and static methods.

Consequently, you also implement one of each of the three method types and name them accordingly. They each return a tuple containing information to help you trace what’s going on, as well as the arguments the method received, such as self and cls. The output will help you understand which objects each of the methods can access.

Note: Naming these parameters self and cls is just a convention—but it’s a strong one in the Python community! You could name them foo and bar and get the same result. However, if you stray from the convention, then you may get disapproving looks from your coworkers or anyone reading your code.

For functionality, all that matters is that you position them first in the parameter list for the method. For maintainability, sanity, and out of respect for others, you should always use self and cls in the classes you define.

Now it’s time to call these demo methods in a new REPL session. Import DemoClass and create an instance of it, then start by calling the instance method:

Python
>>> from demo import DemoClass

>>> obj = DemoClass()

>>> obj.instance_method()
('instance method called', <demo.DemoClass object at 0x100a30d70>)
Copied!

The output confirms that .instance_method() has access to the object instance through the self argument. Python prints the object instance as <demo.DemoClass object at 0x100a30d70>. When you call the instance method, Python replaces the self argument with the instance object, obj.

Instance methods can also access the class itself through the self.__class__ attribute. This makes instance methods powerful in terms of access restrictions. They can modify state on the object instance and on the class itself.

Next, you can try out the class method:

Read the full article at https://realpython.com/instance-class-and-static-methods-demystified/ »


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

March 17, 2025 02:00 PM UTC


Data School

How to calculate "scoring streaks" with pandas 🏀

How to calculate

March Madness, the famous US college basketball tournament, starts tomorrow! 🎉

One term that you&aposll hear a lot during games is "scoring streaks" or "scoring runs". For example, a team that&aposs on a 12-point scoring run has scored 12 points in a row without the other team scoring any points.

So I was wondering: How can we calculate scoring runs using pandas? 🐼

Let&aposs find out! 👇


Example scoring data

Let&aposs pretend this was our scoring data. There&aposs one row for each time a team scored points:

How to calculate

In this case, the largest scoring run was when A scored 9 points in a row.


Identify each scoring run

Now we need to figure out when each scoring run starts!

First, we use the shift() method to shift all of the teams down a row, and store those in a column called previous_team:

How to calculate

Then, we check if team is not equal to previous_team, and store the boolean result in a column called start_of_run:

How to calculate

Do you see how that works?

By checking whether a given team value is equal to the value in the previous row, we now know when each scoring run starts!

Finally, we use the cumsum() method to assign a run_id to each scoring run:

How to calculate

Wait, what just happened?

Any time you do math on a boolean column, True gets treated as 1 and False gets treated as 0. Thus by taking the cumulative sum of the start_of_run column, the run_id increments every time it reaches a True value. (Neat, right?)

Shout out to Josh Devlin&aposs excellent blog post, Calculating Streaks in Pandas, for teaching me this exact approach!


List all scoring runs

Now that each run has been assigned an id, we use a groupby() to show the number of points scored by each team during each run:

How to calculate

That&aposs it! Here&aposs the code from this post, in case you want to experiment with it.

P.S. Want to get better at using pandas for data analysis? Sign up for my FREE 7-hour course, pandas in 30 days!

March 17, 2025 01:49 PM UTC


Real Python

Quiz: LangGraph: Build Stateful AI Agents in Python

By working through this quiz, you’ll revisit how to build LLM workflows and agents in LangGraph, and how LangGraph expands upon LangChain’s capabilities.


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

March 17, 2025 12:00 PM UTC

Quiz: Introducing DuckDB

In this quiz, you’ll test your understanding of the techniques discussed in the Introducing DuckDB tutorial.

As you work through the questions, you’ll review your knowledge of DuckDB and build on what you learned in the tutorial.

To successfully answer all the questions, you’ll need to do some research outside of the tutorial. Embrace this challenge and allow it to enhance your learning journey.


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

March 17, 2025 12:00 PM UTC


Robin Wilson

A load more links

I did a post a while back which was just a lot of links to things I found interesting, mostly in the geospatial/data/programming sphere. Since then I’ve collected a lot more links – so here are some of them. The theme, such as there is, seems to be ‘this would have really helped me about X contracts ago, if it had existed then/I had known about it then’. Make of that what you will…

March 17, 2025 10:30 AM UTC


Python Bytes

#424 We Will Test in Production

<strong>Topics covered in this episode:</strong><br> <ul> <li><strong><a href="https://itnext.io/the-weird-quirk-with-rounding-in-python-e6cd98cb3d55?featured_on=pythonbytes">The weird quirk with rounding in Python</a></strong></li> <li><strong><a href="https://lwn.net/Articles/1010905/?featured_on=pythonbytes">Python interpreter adds tail calls</a></strong></li> <li><a href="https://bsky.app/profile/mathspp.com/post/3lkgp2vplzk2f?featured_on=pythonbytes"><strong>Remove punctuation from a string with translate and maketrans</strong></a></li> <li><strong>Extra, extra, extra</strong></li> <li><strong>Extras</strong></li> <li><strong>Joke</strong></li> </ul><a href='https://www.youtube.com/watch?v=PFAzZ4snjXk' style='font-weight: bold;'data-umami-event="Livestream-Past" data-umami-event-episode="424">Watch on YouTube</a><br> <p><strong>About the show</strong></p> <p>Sponsored by us! Support our work through:</p> <ul> <li>Our <a href="https://training.talkpython.fm/?featured_on=pythonbytes"><strong>courses at Talk Python Training</strong></a></li> <li><a href="https://courses.pythontest.com/p/the-complete-pytest-course?featured_on=pythonbytes"><strong>The Complete pytest Course</strong></a></li> <li><a href="https://www.patreon.com/pythonbytes"><strong>Patreon Supporters</strong></a></li> </ul> <p><strong>Connect with the hosts</strong></p> <ul> <li>Michael: <a href="https://fosstodon.org/@mkennedy"><strong>@mkennedy@fosstodon.org</strong></a> <strong>/</strong> <a href="https://bsky.app/profile/mkennedy.codes?featured_on=pythonbytes"><strong>@mkennedy.codes</strong></a> <strong>(bsky)</strong></li> <li>Brian: <a href="https://fosstodon.org/@brianokken"><strong>@brianokken@fosstodon.org</strong></a> <strong>/</strong> <a href="https://bsky.app/profile/brianokken.bsky.social?featured_on=pythonbytes"><strong>@brianokken.bsky.social</strong></a></li> <li>Show: <a href="https://fosstodon.org/@pythonbytes"><strong>@pythonbytes@fosstodon.org</strong></a> <strong>/</strong> <a href="https://bsky.app/profile/pythonbytes.fm"><strong>@pythonbytes.fm</strong></a> <strong>(bsky)</strong></li> </ul> <p>Join us on YouTube at <a href="https://pythonbytes.fm/stream/live"><strong>pythonbytes.fm/live</strong></a> to be part of the audience. Usually <strong>Monday</strong> at 10am PT. Older video versions available there too.</p> <p>Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to <a href="https://pythonbytes.fm/friends-of-the-show">our friends of the show list</a>, we'll never share it. </p> <p><strong>Brian #1:</strong> <a href="https://itnext.io/the-weird-quirk-with-rounding-in-python-e6cd98cb3d55?featured_on=pythonbytes">The weird quirk with rounding in Python</a></p> <ul> <li>Tom Nijhof-Verheesb</li> <li>With numbers ending in .5, Python always rounds to an even number. <ul> <li>round(0.5) → 0</li> <li>round(1.5) → 2</li> <li>etc</li> </ul></li> <li>This follows IEEE 754</li> <li>You can use decimal if you need a different behavior.</li> </ul> <p><strong>Michael #2:</strong> <a href="https://lwn.net/Articles/1010905/?featured_on=pythonbytes">Python interpreter adds tail calls</a></p> <ul> <li>Ken Jin, a member of the project, has merged a <a href="https://github.com/python/cpython/issues/128563?featured_on=pythonbytes">new set of changes</a> that have been <a href="https://gist.github.com/Fidget-Spinner/497c664eef389622d146d632990b0d21?featured_on=pythonbytes">benchmarked</a> as improving performance by 10% for some architectures.</li> <li>"Speedup is roughly equal to 2 minor CPython releases worth of improvements. For example, CPython 3.12 roughly sped up by 5%.”</li> </ul> <p><strong>Brian #3:</strong> <a href="https://bsky.app/profile/mathspp.com/post/3lkgp2vplzk2f?featured_on=pythonbytes"><strong>Remove punctuation from a string with translate and maketrans</strong></a></p> <ul> <li>Rodrigo</li> <li>“Don't use the method <code>replace</code> to remove punctuation from a Python string. Instead, use the method <code>translate</code>.”</li> </ul> <p><strong>Michael #4:</strong> <strong>Extra, extra, extra</strong></p> <ul> <li><a href="https://www.youtube.com/watch?v=EFmxPMdBqmU&ab_channel=AlanBecker">Animation v Coding, hello world to transformers</a></li> <li><a href="https://www.youtube.com/watch?v=pNlq-EVld70">TypeScript rewritten in Go</a></li> <li><a href="https://www.whatismybrowser.com/guides/how-to-change-your-user-agent/firefox?featured_on=pythonbytes">Firefox lies</a></li> <li><a href="https://us.pycon.org/2025/attend/startup-row/?featured_on=pythonbytes">PyCon’s Startup Row</a></li> <li><a href="https://talkpython.fm/books/python-in-production?featured_on=pythonbytes">Python in Production Book</a></li> </ul> <p><strong>Extras</strong> </p> <p><strong>Joke:</strong> <a href="https://blobs.pythonbytes.fm/star-trek-testing.jpg">Startrek Testing</a></p> <p><img src="https://blobs.pythonbytes.fm/star-trek-testing.jpg" alt="" /></p>

March 17, 2025 08:00 AM UTC


Zato Blog

How to correctly integrate APIs in Python

How to correctly integrate APIs in Python

How to correctly integrate systems in Python

Understanding how to effectively integrate various systems and APIs is crucial. Yet, without a dedicated integration platform, the result will be brittle point-to-point, spaghetti integrations, that never lead to good outcomes.

Read this article about Zato, an open-source integration platform in Python, for an overview of what to avoid and how to do it correctly instead.

More resources

➤ Python API integration tutorials
Python Integration platform as a Service (iPaaS)
What is an Enterprise Service Bus (ESB)? What is SOA?
Open-source iPaaS in Python
What is a Network Packet Broker? How to automate networks in Python?

March 17, 2025 08:00 AM UTC

March 16, 2025


CodersLegacy

Converting LaTeX to PDF in Python: A Step-by-Step Tutorial

If you’ve ever worked with LaTeX, you know it’s an excellent tool for creating professional-quality documents. However, automating the process of converting LaTeX source files to PDFs can sometimes be a bit tedious, especially if you’re managing multiple files or need to integrate this process into a larger Python workflow.

In this tutorial, we’ll explore how to easily convert LaTeX documents into PDF files using a dedicated Python library that wraps the pdflatex command.


Table of Contents


Prerequisites

Before getting started, ensure that you have the necessary LaTeX packages installed on your system. If you encounter errors like “pdflatex not found”, run the following command (or its equivalent on your system):

Python
sudo apt-get install texlive-latex-base texlive-latex-extra texlive-fonts-extra

This will install the essential LaTeX packages required for pdflatex to function correctly.

Additionally, you’ll need Python installed along with the pdflatex library. If you haven’t installed the library yet, you can typically do so via pip:

Python
pip install pdflatex

Creating a PDF from a .tex File

Let’s start with the most straightforward use-case: generating a PDF from an existing .tex file.

Begin by importing the PDFLaTeX class:

Python
from pdflatex import PDFLaTeX

Instantiate from a .tex File using the helper method from_texfile to create a PDFLaTeX object:

Python
pdfl = PDFLaTeX.from_texfile('my_file.tex')

Call the create_pdf method. This method returns three things:

Python
pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)

The keep_pdf_file and keep_log_file parameters (both default to False) allow you to retain the files on your filesystem if needed. Otherwise, the module cleans up after itself, leaving no trace unless explicitly requested.


Creating a PDF from a Binary String

There may be scenarios where your LaTeX content isn’t stored in a file but is generated dynamically (for instance, from a web template or user input). In such cases, you can create a PDF directly from a binary string.

Python
import pdflatex

with open('my_file.tex', 'rb') as f:
    pdfl = pdflatex.PDFLaTeX.from_binarystring(f.read(), 'my_file')
    
pdf, log, cp = pdfl.create_pdf()

The PDF is now available as a binary string which you can save to disk, serve via a web application, or further process as needed.

The post Converting LaTeX to PDF in Python: A Step-by-Step Tutorial appeared first on CodersLegacy.

March 16, 2025 06:07 PM UTC

March 15, 2025


TechBeamers Python

Python Game Code: The Ultimate Pygame Guide

This guide teaches you how to write a unique and engaging Python game code, we call it Neon Racer. The focus is on smooth gameplay, clear instructions, and a modular approach. Follow along to understand how each piece (such as setting up the window, player movement, obstacles, pickups, scoring, and game over conditions) fits into […]

Source

March 15, 2025 04:05 PM UTC

March 14, 2025


TestDriven.io

Django Query Optimization - Defer, Only, and Exclude

In this article, we'll look at the differences between Django QuerySet's defer, only, and exclude methods.

March 14, 2025 10:28 PM UTC


Robin Wilson

My talk at FOSS4G UK South West 2024

As always, this post is very delayed – apologies. In fact, I was encouraged to write this by a friend who I see at PyData Southampton (Hi, if you’re reading this!). I mentioned my talk in passing to her, and she asked if I’d blogged about it yet. I admitted that I hadn’t, and promised I would by the next PyData Southampton. Well, I totally failed at that – but there is another PyData Southampton meetup on Tuesday, so I’m going to get it done in time for that.

The FOSS4G UK South West conference 2024 took place in Bristol on 12th November. I gave a talk there entitled Using cloud-native geospatial technologies to build a web app for analysing and reducing flood risk, talking about some of the work I’ve done with the company I’m currently working with: Rebalance Earth.

The talk covers the development of a web app for looking at assets (businesses, buildings, substations etc) that are at risk from flooding in the UK, and comparing various flood scenarios to understand how risk could be reduced by Natural Flood Management strategies such as river restoration. After introducing Rebalance Earth and the web app itself, I talk about the technologies behind it and the ‘cloud native’ manner in which it was designed. I specifically cover generating Mapbox Vector Tiles on-the-fly from a PostGIS database, and generating raster tiles on-the-fly from COG files stored in cloud storage.

Full slides are available here. There is also a video recording of the talk available, but it’s a bit hard to watch as you can’t see the slides on the video.

Once you’ve had a look at my talk, don’t forget to check out the other talks that were given at the conference, they were great!

March 14, 2025 08:41 PM UTC


Python Insider

Python 3.14.0 alpha 6 is out

Here comes the penultimate alpha.

https://www.python.org/downloads/release/python-3140a6/

This is an early developer preview of Python 3.14

Major new features of the 3.14 series, compared to 3.13

Python 3.14 is still in development. This release, 3.14.0a6, is the sixth of seven planned alpha releases.

Alpha releases are intended to make it easier to test the current state of new features and bug fixes and to test the release process.

During the alpha phase, features may be added up until the start of the beta phase (2025-05-06) and, if necessary, may be modified or deleted up until the release candidate phase (2025-07-22). Please keep in mind that this is a preview release and its use is not recommended for production environments.

Many new features for Python 3.14 are still being planned and written. Among the new major new features and changes so far:

The next pre-release of Python 3.14 will be the final alpha, 3.14.0a7, currently scheduled for 2025-04-08.

More resources

And now for something completely different

March 14 is celebrated as pi day, because 3.14 is an approximation of π. The day is observed by eating pies (savoury and/or sweet) and celebrating π. The first pi day was organised by physicist and tinkerer Larry Shaw of the San Francisco Exploratorium in 1988. It is also the International Day of Mathematics and Albert Einstein’s birthday. Let’s all eat some pie, recite some π, install and test some py, and wish a happy birthday to Albert, Loren and all the other pi day children!

Enjoy the new release

Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organisation contributions to the Python Software Foundation.

Regards from Helsinki as fresh snow falls,

Your release team,
Hugo van Kemenade @hugovk
Ned Deily @nad
Steve Dower @steve.dower
Łukasz Langa @ambv

March 14, 2025 01:27 PM UTC


Real Python

The Real Python Podcast – Episode #243: Manage Projects With pyproject.toml & Explore Polars LazyFrames

How can you simplify the management of your Python projects with one file? What are the advantages of using LazyFrames in Polars? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder's Weekly articles and projects.


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

March 14, 2025 12:00 PM UTC


Django Weblog

DSF member of the month - Cory Zue

For March 2025, we welcome Cory Zue (@coryzue.com) as our DSF member of the month! ⭐

Cory Zue is a Django developer for many years. He is currently a member of the DSF Social Media Working Group and he has been a DSF member since octobre 2022.
You can learn more about Cory by checking out his website or visiting Cory's GitHub Profile.

Let’s spend some time getting to know Cory better!

Can you tell us a little about yourself (hobbies, education, etc)

I'm a programmer-turned-manager-turned-entrepreneur and currently run a portfolio of businesses on my own (using Django of course!).

I grew up in Massachusetts and studied Computer Science at MIT where I met the founders of Dimagi, where I ended up as CTO for 10 years before starting my own businesses. In 2016, I moved to Cape Town, South Africa for a "temporary" relocation, and have been here ever since. These days my main hobbies include surfing, trail running, and exploring nature with my wife and two boys.

How did you start using Django?

My first major Django project was working on an SMS-based system that helped with the distribution of millions of bednets in Nigeria. It was built on top of a Django-based platform called RapidSMS that was initially developed by UNICEF. After that I worked on several other RapidSMS systems before eventually leading Dimagi's CommCare server team. CommCare eventually became -- to my knowledge -- the largest open source Django codebase in terms of contributions/commits.

What other framework do you know and if there is anything you would like to have in Django if you had magical powers?

I still love Django and use it for most projects that need a backend. That said, I find Django's "hands off" approach to modern front end development to be a big barrier for people who aren't already familiar with the framework.

If I had magical powers I would convince the Django community that it is worth providing some out-of-the-box support for modern front end tooling like TailwindCSS or a JavaScript bundler. I'd also try to get official "starter projects" built into the framework that show how you can use Django with some of the more popular front end options like React and HTMX.

What projects are you working on now?

My main project right now is SaaS Pegasus, which is a Django codebase creator that helps you spin up new projects more efficiently by bundling in even more batteries than Django itself. This includes things like configuring auth, front end, and deployment, but also has some more powerful features like multi-tenancy and billing baked in.

One of the great things about running Pegasus is that I can justify building new Django apps as dogfooding the product. So I always have other Django projects I'm working on. Right now the biggest one is a RAG chat-with-your-data LLM project called Scriv.ai.

Within the Django community my main contributions are in the form of writing in-depth guides to using Django, as well as pitching in on the Social Media working group to help grow Django's audience.

Which Django libraries are your favorite (core or 3rd party)?

It's hard to go with anything other than the ORM (and migrations framework), which I still feel is Django's greatest and most important feature. It just fits my brain much better than SQLAlchemy or other options I've used.

One lesser-known library I'll shout out that I have been enjoying lately is django-cotton, which provides a nice little layer of syntactic sugar and tooling that makes working with components in Django templates much nicer.

What are the top three things in Django that you like?

  1. The ORM + migrations.

  2. The community.

  3. That nearly every backend use case I have already has a feature that's been built to accommodate it (e.g. middleware, messages, i18n, etc.). I feel like the modern JavaScript frameworks I've used are way behind on this front.

What would you recommend to someone who wants to start out as an entrepreneur like you?

I have an entire talk/article about this!

But if I were to emphasize the most important part that worked for me, it was creating enough space in my life for deep, uninterrupted work and structuring it in a way that I never ran out of money or energy while I was trying (by working part time while I was getting started). In general, the path to success usually takes a long time, so giving yourself plenty of time is really important. The tactics you can figure out as you go, but the space and time to do it is the most important thing to have in place. Your main goal is not to quit.

Is there anything else you'd like to say?

Thank you for including me in this series!


Thank you for doing the interview, Cory!

March 14, 2025 11:53 AM UTC


Talk Python to Me

#496: Scaf: Complete blueprint for new Python Kubernetes projects

Today we explore the wild world of Python deployment with my friend, Calvin Hendryx-Parker from Six Feet Up. We’ll tackle some of the biggest challenges in taking a Python app from “it works on my machine” to production, covering inconsistent environments, conflicting dependencies, and sneaky security pitfalls. Along the way, Calvin shares how containerization with Docker and Kubernetes can both simplify and complicate deployments, especially for smaller teams. Finally, we’ll introduce Scaf, a powerful project blueprint designed to give developers a rock-solid start on Python web projects of all sizes. <br/> <br/> Get notified when the <a href="https://talkpython.fm/books/python-in-production"><em>Talk Python in Production</em> book</a> goes live and <a href="https://talkpython.fm/books/python-in-production">read the first third online</a> right now.<br/> <br/> <strong>Episode sponsors</strong><br/> <br/> <a href='https://talkpython.fm/connect'>Posit</a><br> <a href='https://talkpython.fm/devopsbook'>Python in Production</a><br> <a href='https://talkpython.fm/training'>Talk Python Courses</a><br/> <br/> <h2 class="links-heading">Links from the show</h2> <div><strong>Calvin Hendryx-Parker</strong>: <a href="https://github.com/calvinhp?featured_on=talkpython" target="_blank" >github.com</a><br/> <strong>Scaf on GitHub</strong>: <a href="https://github.com/sixfeetup/scaf?featured_on=talkpython" target="_blank" >github.com</a><br/> <strong>Scaf on GitHub (duplicate)</strong>: <a href="https://github.com/sixfeetup/scaf?featured_on=talkpython" target="_blank" >github.com</a><br/> <br/> <strong>"Deploy the Dream" song</strong>: <a href="https://blobs.talkpython.fm/deploy-the-dream-talk-python.mp3" target="_blank" >deploy-the-dream-talk-python.mp3</a><br/> <br/> <strong>CloudDevEngineering YouTube Channel</strong>: <a href="https://www.youtube.com/@CloudDevEngineering" target="_blank" >youtube.com</a><br/> <strong>TechWorld with Nana YouTube Channel</strong>: <a href="https://www.youtube.com/@TechWorldwithNana" target="_blank" >youtube.com</a><br/> <strong>Tilt (Kubernetes Dev Tool)</strong>: <a href="https://tilt.dev/?featured_on=talkpython" target="_blank" >tilt.dev</a><br/> <strong>Talos (Minimal OS for Kubernetes)</strong>: <a href="https://www.talos.dev/?featured_on=talkpython" target="_blank" >talos.dev</a><br/> <strong>Traefik Reverse Proxy</strong>: <a href="https://traefik.io/traefik/?featured_on=talkpython" target="_blank" >traefik.io</a><br/> <strong>Sealed Secrets on GitHub</strong>: <a href="https://github.com/bitnami-labs/sealed-secrets?featured_on=talkpython" target="_blank" >github.com</a><br/> <strong>Argo CD Documentation</strong>: <a href="https://argo-cd.readthedocs.io/en/stable/?featured_on=talkpython" target="_blank" >readthedocs.io</a><br/> <strong>MailHog on GitHub</strong>: <a href="https://github.com/mailhog/MailHog?featured_on=talkpython" target="_blank" >github.com</a><br/> <strong>Next.js</strong>: <a href="https://nextjs.org/?featured_on=talkpython" target="_blank" >nextjs.org</a><br/> <strong>Cloud Custodian</strong>: <a href="https://cloudcustodian.io/?featured_on=talkpython" target="_blank" >cloudcustodian.io</a><br/> <strong>Valky (Redis Replacement)</strong>: <a href="https://valkey.io/?featured_on=talkpython" target="_blank" >valkey.io</a><br/> <strong>“The ‘Works on My Machine’ Certification Program” (Coding Horror)</strong>: <a href="https://blog.codinghorror.com/the-works-on-my-machine-certification-program/?featured_on=talkpython" target="_blank" >blog.codinghorror.com</a><br/> <strong>NVIDIA’s First Desktop AI PC (Ars Technica)</strong>: <a href="https://arstechnica.com/ai/2025/01/nvidias-first-desktop-pc-can-run-local-ai-models-for-3000/?featured_on=talkpython" target="_blank" >arstechnica.com</a><br/> <strong>Kind (Kubernetes in Docker)</strong>: <a href="https://kind.sigs.k8s.io/?featured_on=talkpython" target="_blank" >kind.sigs.k8s.io</a><br/> <br/> <strong>Updated Effective PyCharm Course</strong>: <a href="https://training.talkpython.fm/courses/explore_pycharm/mastering-pycharm-ide" target="_blank" >training.talkpython.fm</a><br/> <strong>Talk Python in Production book</strong>: <a href="https://talkpython.fm/books/python-in-production" target="_blank" >talkpython.fm/books/python-in-production</a><br/> <strong>Watch this episode on YouTube</strong>: <a href="https://www.youtube.com/watch?v=-GWj3hKnGOM" target="_blank" >youtube.com</a><br/> <strong>Episode transcripts</strong>: <a href="https://talkpython.fm/episodes/transcript/496/scaf-complete-blueprint-for-new-python-kubernetes-projects" target="_blank" >talkpython.fm</a><br/> <br/> <strong>--- Stay in touch with us ---</strong><br/> <strong>Subscribe to Talk Python on YouTube</strong>: <a href="https://talkpython.fm/youtube" target="_blank" >youtube.com</a><br/> <strong>Talk Python on Bluesky</strong>: <a href="https://bsky.app/profile/talkpython.fm" target="_blank" >@talkpython.fm at bsky.app</a><br/> <strong>Talk Python on Mastodon</strong>: <a href="https://fosstodon.org/web/@talkpython" target="_blank" ><i class="fa-brands fa-mastodon"></i>talkpython</a><br/> <strong>Michael on Bluesky</strong>: <a href="https://bsky.app/profile/mkennedy.codes?featured_on=talkpython" target="_blank" >@mkennedy.codes at bsky.app</a><br/> <strong>Michael on Mastodon</strong>: <a href="https://fosstodon.org/web/@mkennedy" target="_blank" ><i class="fa-brands fa-mastodon"></i>mkennedy</a><br/></div>

March 14, 2025 08:00 AM UTC


Seth Michael Larson

Fediverse Donut Club (#FediDonutFriday)

At a past job there was an employee-run "donut club" where members would rotate every week bringing in donuts for everyone else. By the time that I joined this club there was over 30 people meaning almost everyone on the team was bringing in donuts once or twice a year.

When it was your turn to bring donuts you got to "host" the boxes of donuts in your cubicle meaning everyone in the donut club came to you, said hello, introduced themselves, and all that.

I didn't know it at the time, but donut club was an amazing tool for socializing and organizing. We were enjoying our donuts, but we were also strengthening our bonds with coworkers. Some of the people I met in donut club I'm still good friends with. Like all good friends we sometimes discuss labor conditions and help each other with job hunting, negotiating, and being paid fairly.

Why make a donut club in the Fediverse?

I propose the creation of a "Fediverse Donut Club" with an every-other-week #FediDonutFriday event where everyone in Fediverse Donut Club procures and shares pictures of donuts to meet others in the Fediverse.

I'm interested in how we can make online communities more "horizontal" like the real world, where people aren't divided only by their hyper-specific interests and bubbles. This is an experiment to see if a few posts in the Fediverse can get you out in your local community bakery for an occasional donut and connecting with others online.

Seems like a good deal to me! 🍩

How to join Fediverse Donut Club

If you're not sure whether your post will be discoverable (due to your instance being small, for example) you can direct message me on Mastodon with the hashtag.

When is the next #FediDonutFriday?

#FediDonutFriday is every two weeks starting Friday, March 14th 2025. I created the below QR code to add a reminder to any calendar.

Note there's no "responding yes", tracking, or surveillance in this ICS file, it's a simple recurring event. You can also import the ICS file manually if you'd like.

March 14, 2025 12:00 AM UTC

March 13, 2025


Python Morsels

Alternatives to Python's "break" statement

Python's break statement is handy for breaking out of a loop. But break statements can often be replaced by a more readable looping helper function.

Table of contents

  1. Using a containment check instead
  2. Checking whether some/every item matches a condition
  3. Finding the first matching value
  4. Collecting items until a condition is met
  5. Consider break statement alternatives

Using a containment check instead

Python's break statement is often used when you need an early break condition, that is a condition which would indicate that you don't need to loop any further because you've found what you're looking for.

For example here's a loop that checks for a specific value and then breaks:

color_options = ["blue", "green", "purple"]

is_purple_an_option = False
for color in color_options:
    if color == "purple":
        is_purple_an_option = True
        break

That for loop checks whether our iterable contains a certain value at least once. If it does, we flip a boolean variable from False to True.

Instead of using that for loop, we could use Python's in operator on our iterable:

color_options = ["blue", "green", "purple"]

is_purple_an_option = "purple" in color_options

All iterables support the in operator and in fact on some iterables (e.g. sets and dictionaries) it's even faster than looping (see list containment checks).

Checking whether some/every item matches a condition

What if we're checking for …

Read the full article: https://www.pythonmorsels.com/break-statement-alternatives/

March 13, 2025 04:05 PM UTC