skip to navigation
skip to content

Planet Python

Last update: September 08, 2025 04:43 AM UTC

September 06, 2025


TechBeamers Python

Python Memory Tricks: Optimize Your Code for Efficiency in 2025

Learn 8 tricks to reduce memory use in Python programs. Fix memory leaks, pick better data structures, and work with large amounts of data more easily. Use tools like generators and slots with simple code examples. These tips help make your programs faster and stop MemoryErrors.

Source

September 06, 2025 07:00 PM UTC


Rodrigo Girão Serrão

uv cheatsheet

Cheatsheet with the most common and useful uv commands to manage projects and dependencies, publish projects, manage tools, and more.

This cheatsheet lists the most commonly used commands and should be more than enough for you to get started using uv. For more advanced use cases, check the uv docs and its guides.

Written for uv version 0.8.15.

Creating projects 🧱

uv init Initialise a project in the current directory
uv init myproj Initialise a project myproj in the directory myproj
uv init --app --package ... Initialise a packageable app (e.g., CLI, web app, ...)
uv init --lib --package ... Initialise a packageable library (code you import)
uv init --python 3.X ...1 Use Python 3.X for your project

Managing project dependencies 🧩

uv add requests Add requests as a dependency
uv add A B C Add A, B, and C as dependencies
uv add -r requirements.txt Add dependencies from the file requirements.txt
uv add --dev pytest Add pytest as a development dependency
uv run pytest Run the pytest executable that is installed in your project
uv remove requests Remove requests as a dependency
uv remove A B C Remove A, B, C, and their transitive dependencies
uv tree See the project dependencies tree
uv lock --upgrade Upgrade the dependencies' versions

Project lifecycle management 🔄

uv build Build your packageable project
uv publish Publish your packageable project to PyPI
uv version Check your project version
uv version --bump major Bump project major version (e.g., 0.3.2 -> 1.0.0)
uv version --bump minor --bump beta Bump minor version into a beta (e.g., 1.0.0 -> 1.1.0b1 or 1.1.0b1 -> 1.1.0b2)
uv version --bump rc Bump version into release candidate (e.g., 1.1.0b1 -> 1.1.0rc1 or 1.1.0rc1 -> 1.1.0rc2)
uv version --bump stable Turn into a stable version (e.g., 1.1.0rc1 -> 1.1.0)

Managing tools ⚒️

uv tool run pytest Run pytest in an isolated environment
uv tool run textual-demo --from textual Run the command textual-demo from the package textual
uvx ... Alias for uv tool run ...
uv tool install ruff Install ruff in an isolated environment but make it globally available
uv tool install --with dep ... Install the given tool with extra dependencies (e.g., install a tool with its plugins)
uv tool list List all tools installed
uv tool upgrade ruff Upgrade the ruff tool
uv tool upgrade --all Upgrade all tools
uv tool uninstall ruff Uninstall ruff
uv tool install -e .2 Install the current packageable project in editable mode

Working with scripts 📜

uv init --script myscript.py Initialise the script myscript.py
uv init --script myscript.py --python 3.X Initialise the script myscript.py and pin it to version 3.X
uv add click --script myscript.py Add the dependency click to the script
uv remove click --script myscript.py Remove the dependency click from the script
uv run myscript.py Run the script myscript.py
uv run --python 3.X myscript.py Run the script with the given Python version
uv run --with click myscript.py Run the script along with...

September 06, 2025 05:36 PM UTC


Hugo van Kemenade

Ready prek go!

I’ve been using prek recently as a drop-in replacement for pre-commit.

It uses uv for managing Python virtual environments and dependencies, is rewritten in Rust (because of course) and uses the same .pre-commit-config.yaml as pre-commit.

Its homepage says it’s not yet production ready, but several projects like Apache Airflow and PDM are already using it. I’ve been using it for a while and reporting issues as I find them; the maintainer is quick with fixes and releases. All the hooks I need are now supported.

Getting started #

First install using one of the many methods, then:

cd my-repo
pre-commit uninstall # remove the old hooks
prek install # install the new hooks
prek run --all-files # run all lints on all files
git commit -m "my commit" # run on the changed files in a commit

Benchmarks #

prek is noticeably quicker at installing hooks.

  • ⚡ About 10x faster than pre-commit and uses only a third of disk space.

This 10x is a comparison of installing hooks using the excellent hyperfine benchmarking tool.

Here’s my own comparison.

❯ hyperfine \
--prepare 'rm -rf ~/.cache/prek/ && rm -rf ~/.cache/pre-commit && rm -rf ~/.cache/uv' \
--setup 'prek --version && pre-commit --version' \
'prek install-hooks' \
'pre-commit install-hooks'

Results #

pre-commit prek Times faster
run --all-files 17m13s 7m59s 2.16
install-hooks 10m48s 2m24s 4.50
hyperfine 39.841s 5.539s 7.19

The hyperfine results:

Benchmark 1: prek install-hooks
 Time (mean ± σ): 5.539 s ± 0.176 s [User: 8.973 s, System: 5.692 s]
 Range (min … max): 5.231 s … 5.834 s 10 runs

Benchmark 2: pre-commit install-hooks
 Time (mean ± σ): 39.841 s ± 2.017 s [User: 19.760 s, System: 8.203 s]
 Range (min … max): 36.930 s … 43.976 s 10 runs

Summary
 prek install-hooks ran
 7.19 ± 0.43 times faster than pre-commit install-hooks

Give it a try and give it a !

Bonus #

These are the aliases I have set for pre-commit and prek:

alias pci="pre-commit install --allow-missing-config"
alias pcu="pre-commit uninstall"
alias pca="pre-commit autoupdate --jobs 0"
alias pcr="pre-commit run --all-files"
alias pki="prek install --allow-missing-config"
alias pku="prek uninstall"
alias pka="prek autoupdate --jobs 0"
alias pkr="prek run --all-files"

Where:


Header photo: AH-1G Aircraft Maintenance Test Flight Handbook and handwritten checklist for helicopters in the San Diego Air and Space Museum Archive, with no known copyright restrictions.

September 06, 2025 03:50 PM UTC

September 05, 2025


Django Weblog

DSF at EuroPython 2025: Celebrating 20 years of Django

This year, the Django Software Foundation (DSF) was invited by EuroPython to come to the event, showcase the framework and the vibrant community around it. The DSF had a booth in the community area where attendees could learn more about Django and meet maintainers.

This year was extra special: Django’s 20th birthday was right at the beginning of the conference! The milestone was marked in style, starting on Wednesday evening at Pyvo, the local Python community meetup in Prague, where we celebrated with a cake.

Collage of 4 pictures: three participants smiling; two pictures of someone holding a cake; close-up of the cake that says '20 Happy birthday Django!'. With EuroPython 2025 and Django branding in-between the pics

On Friday, the celebration continued with an open-space gathering at the conference — and, of course, another cake 🎂. For people who missed this, there are other local Django birthday events running through the rest of 2025!

Collage of 4 pictures: group photo of birthday celebrations with a cake on a table; close-up of participants; close-up of the cake; people blowing candles. With EuroPython 2025 and Django branding in-between the pics

View all local 20th birthday events

Adding to the festive atmosphere, the DSF shared stickers co-branded with their unofficial pony mascot and the EuroPython and EuroPython Society logos. These became an instant hit with attendees, combining Django’s playful mascot with EuroPython Society’s identity.

Close-up of a Django pony sticker someone is holding. The pony is smiling and wears a EuroPython Society shirt

The Django community was also active during the sprint weekend. Over two days, 21 participants worked on Django, tackling 12 issues and merging 4 pull requests. For newcomers, it was a welcoming way to start contributing; for experienced developers, it was a chance to share knowledge and push the project forward together.

Collage of 3 pictures: sprint participants all around a table working together with laptops; 3 people troubleshooting together; Tom looking thoughtful. With EuroPython 2025 and Django branding in-between the pics.

We asked the members of the Django Software Foundation attending EuroPython how they liked EuroPython and this is what they said: 

The talks and tutorials were so great and I got to witness amazing projects from this community. This was my first europython conference and let me tell you, this community overdelivered. It was also my first time organizing Django Girls outside Africa. Django Girls Prague was amazing.\

Just the perfect mixture of catching up with people I know, meeting people I don’t know, learning new things. Time well spent chatting w/ Python veterans and also first-timers. Volunteering there was ACE, and I’m thankful we got to have a booth and birthday cake for Django 🎂\

It was my first EuroPython, it felt really special! I was surrounded by wonderful people, and it was an amazing experience to volunteer at our community booth.\

We’re delighted the DSF joined us this year. If you’re part of a foundation and would like to have a booth at EuroPython, keep an eye out for our Call for Communities next year.


Thank you to EuroPython Vice Chair and DSF Individual member Mia Bajić for reporting back on the event ❤️. And thank you to our volunteers Tom Carrick, Thibaud Colas, Raffaella Suardini, and Alex Gómez who represented our foundation at the conference. As well as to Doreen Nangira who ran the Django Girls+ workshop at the conference!

September 05, 2025 02:02 PM UTC


Real Python

The Real Python Podcast – Episode #264: Large Language Models on the Edge of the Scaling Laws

What's happening with the latest releases of large language models? Is the industry hitting the edge of the scaling laws, and do the current benchmarks provide reliable performance assessments? This week on the show, Jodie Burchell returns to discuss the current state of LLM releases.


[ 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 ]

September 05, 2025 12:00 PM UTC


EuroPython

Django Software Foundation at EuroPython 2025: Celebrating 20 Years of the Django framework

At EuroPython, we’re always glad to welcome friends from other foundations. This year, the Django Software Foundation (DSF) joined us to showcase the framework and the vibrant community around it.

The DSF had a booth in the community area where attendees could learn more about Django and meet maintainers.

This year was extra special: Django turned 20 years old! The milestone was marked in style, starting on Wednesday evening at Pyvo, the local Python community meetup in Prague, where we celebrated with a cake.

alt

On Friday, the celebration continued with an open-space gathering at the conference — and, of course, another cake 🎂. For people who missed this, there are other local Django birthday events running through the rest of 2025! 

alt

Adding to the festive atmosphere, the DSF shared stickers co-branded with their unofficial pony mascot and the EuroPython and EuroPython Society logos. These became an instant hit with attendees, combining Django’s playful mascot with EuroPython Society’s identity.

alt

The Django community was also active during the sprint weekend. Over two days, 21 participants worked on Django, tackling 12 issues and merging 4 pull requests. For newcomers, it was a welcoming way to start contributing; for experienced developers, it was a chance to share knowledge and push the project forward together.

alt

We asked the members of the Django Software Foundation attending EuroPython how they liked EuroPython and this is what they said: 

The talks and tutorials were so great and I got to witness amazing projects from this community. This was my first EuroPython conference and let me tell you, this community overdelivered. It was also my first time organizing Django Girls outside Africa. Django Girls Prague was amazing.

- Doreen Nangira - Django Girls organizer

Just the perfect mixture of catching up with people I know, meeting people I don’t know, learning new things. Time well spent chatting w/ Python veterans and also first-timers. Volunteering there was ACE, and I’m thankful we got to have a booth and birthday cake for Django 🎂

- Thibaud Colas - President, Django Software Foundation

It was my first EuroPython, it felt really special! I was surrounded by wonderful people, and it was an amazing experience to volunteer at our community booth.

- Raffaella Suardini - Djangonaut Space organizer

We’re delighted the DSF joined us this year. If you’re part of a foundation and would like to have a booth at EuroPython, keep an eye out for our Call for Communities next year.

September 05, 2025 09:09 AM UTC


Brian Okken

Python People podcast now at pythontest.com/pythonpeople

Like the recent archival of Test and Code, the Python People podcast has also moved. Python People is now at pythontest.com/pythonpeople.

Is it also archived? As in done?

I don’t think so. I think I might start that up again at some point.

But for now, it’s on a long-ish term pause.

BTW, the RSS feeds for both Python People and Test and Code should be redirected correctly, so you shouldn’t have to change anything in your podcast player.

September 05, 2025 12:00 AM UTC

September 04, 2025


Trey Hunner

Customizing your Python REPL's color scheme (Python 3.14+)

Did you know that Python 3.14 will include syntax highlighting in the REPL?

Python 3.14 is due to be officially released in about a month. I recommended tweaking your Python setup now so you’ll have your ideal color scheme on release day.

But… what if the default syntax colors don’t match the colors that your text editor uses?

Well, fortunately you can customize your color scheme!

Warning: I am recommending using an undocumented private module (it has an _-prefixed name) which may change in future Python versions. Do not use this module in production code.

Installing Python 3.14

Don’t have Python 3.14 installed yet?

If you have uv installed, you can run this command to launch Python 3.14:

1
$ uv run --python 3.14 python

That will automatically install 3.14 (if you don’t have it yet) and run it.

Setting a theme

I have my terminal colors set to the Solarized Light color palette and I have Vim use a Solarized Light color scheme as well.

The REPL doesn’t quite match my text editor by default:

The numbers, comments, strings, and keywords are all different colors than my text editor.

This code makes the Python REPL use nearly the same syntax highlighting as my text editor:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from _colorize import set_theme, default_theme, Syntax, ANSIColors

set_theme(default_theme.copy_with(
    syntax=Syntax(
        keyword=ANSIColors.GREEN,
        builtin=ANSIColors.BLUE,
        comment=ANSIColors.INTENSE_BLUE,
        string=ANSIColors.CYAN,
        number=ANSIColors.CYAN,
        definition=ANSIColors.BLUE,
        soft_keyword=ANSIColors.BOLD_GREEN,
        op=ANSIColors.INTENSE_GREEN,
        reset=ANSIColors.RESET + ANSIColors.INTENSE_GREEN,
    ),
))

Check it out:

Neat, right?

But… I want this to be enabled by default!

Using a PYTHONSTARTUP file

You can use a PYTHONSTARTUP file to run code every time a new Python process starts.

If Python sees a PYTHONSTARTUP environment variable when it starts up, it will open that file and evaluate the code within it.

I have this in my ~/.zshrc file to set the PYTHONSTARTUP environment variable to ~/.startup.py:

1
2
# Setup python-launcher to use startup file
export PYTHONSTARTUP=$HOME/.startup.py

In my ~/.startup.py file, I have this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def _main():
    """Everything's in a function to avoid polluting the global scope."""
    try:
        from _colorize import set_theme, default_theme, Syntax, ANSIColors
    except ImportError:
        pass  # Python 3.13 and below
    else:
        # Define Solarized Light colors
        solarized_light_theme = default_theme.copy_with(
            syntax=Syntax(
                keyword=ANSIColors.GREEN,
                builtin=ANSIColors.BLUE,
                comment=ANSIColors.INTENSE_BLUE,
                string=ANSIColors.CYAN,
                number=ANSIColors.CYAN,
                definition=ANSIColors.BLUE,
                soft_keyword=ANSIColors.BOLD_GREEN,
                op=ANSIColors.INTENSE_GREEN,
                reset=ANSIColors.RESET + ANSIColors.INTENSE_GREEN,
            ),
        )
        set_theme(solarized_light_theme)

_main()  # _main avoids name collision, in case python -i is used
del _main  # Delete _main from global scope

Note that:

  1. I put all relevant code within a _main function so that the variables I set don’t remain in the global scope of the Python REPL (they will by default)
  2. I call the _main function and then delete the function afterward, again so the _main variable doesn’t stay floating around in my REPL
  3. I use try-except-else to ensure errors don’t occur on Python 3.13 and below

Also note that the syntax highlighting in the new REPL is not as fine-grained as many other syntax highlighting tools. I suspect that it may become a bit more granular over time, which may break the above code.

The _colorize module is currently an internal implementation detail and is deliberately undocumented. Its API may change at any time, so the above code may break in Python 3.15. If that happens, I’ll just update my PYTHONSTARTUP file at that point.

Packaging themes

I’ve stuck all of the above code in a ~/.startup.py file and I set the PYTHONSTARTUP environment variable on my system to point to this file.

Instead of manually updating a startup file, is there any way to make these themes installable?

Well, if a .pth file is included in Python’s site-packages directory, that file (which must be a single line) will be run whenever Python starts up. In theory, a package could use such a file to import a module and then call a function that would set the color scheme for the REPL. My dramatic package uses (cough abuses cough) .pth files in this way.

This sounds like a somewhat bad idea, but maybe not a horrible idea.

If you do this, let me know.

What’s your theme?

Have you played with setting a theme in your own Python REPL?

What theme are you using?

September 04, 2025 07:42 PM UTC


Django Weblog

Last call for DjangoCon US 2025 tickets!

DjangoCon US starts next week in Chicago, IL on September 8-12th, 2025!

With three amazing keynotes and over fifty presentations over three days, join us in person or online where you can watch presentations on your own schedule or stream live with us during the live event.

Can't make it to Chicago? Our online tickets give you the best of both worlds. Watch live as it happens or catch up on your own schedule – all talks will be available to stream throughout the conference and beyond. You'll get the same great content, participate in online discussions, and join our vibrant community from wherever you are. Plus, with two days of virtual sprints alongside our in-person sprints, online attendees can contribute to Django projects and collaborate with the community just like everyone else.

Get your ticket today before it's too late! Check out the full schedule, visit 2025.djangocon.us for more details, or contact us at hello@djangocon.us with any questions.

September 04, 2025 05:01 PM UTC

Keyboard shortcuts in Django via GSoC 2025

This summer I participated in the Google Summer of Code program with Django. My work focused on introducing keyboard shortcuts to the Django admin interface which led to a new package: django-admin-keyshortcuts.

Proposal and Community Discussions

My original GSoC proposal was to improve the existing django-admin-keyboard-shortcuts package maintained by one of my mentors, Tom. The plan was to fix bugs, add new keyboard shortcuts, build a command palette, and eventually merge these features into Django's core admin. I initially thought getting my GSoC proposal accepted meant I could dive straight into coding. But Tom explained that Django has its own process for new features, which starts off with community discussions.

After posting on the forum and gathering feedback, we decided to focus on keyboard shortcuts only, and continue exploring that in packages rather than target Django core immediately. This way the feature can be tested and improved more quickly without waiting on Django's long release cycle.

The accessibility team helped drafting keyboard shortcuts outlining key requirements and expected outcomes, in particular making sure shortcuts would be widely compatible with browsers and assistive technologies. That document served as the base for developing django-admin-keyshortcuts.

django-admin-keyshortcuts

This package adds useful keyboard shortcuts to the Django admin interface. The goal is to make the Django admin interface faster to navigate and more accessible to keyboard-first users. Here are some of the shortcuts we have added so far:

The package also comes with a keyboard shortcuts dialog, crucial so users of the admin can discover those new features:

Screenshot of the keyboard shortcuts dialog displayed as a modal over the Django admin interface. It displays 6 shortcuts

Developers can also define custom shortcuts by extending admin templates. Detailed instructions can be found in the package's README.

Under the hood, the package uses the hotkey library for handling shortcuts. The library seems to be well maintained (compared to other alternatives) and is used for keyboard shortcuts in GitHub.

What's next

We have made a lot of progress, but there's still work to do before we can push to merge this functionality inside Django core.

Implementation issues

Right now, there are a couple of known problems:

To address these we may wait for the hotkey library maintainers to implement the necessary fixes, or look for alternatives.

Gather feedback

We want more users to try it out! Testing in different scenarios will help find bugs faster and improve the package. The default shortcut set is also small, we need feedback to determine which shortcuts are most useful. We also plan to list the package on a new "Experiments" section on the new Django Ecosystem page to make it more visible.

But for now, try it out and let us know what you think! We have a static admin demo for people to directly try the shortcuts. Or install django-admin-keyshortcuts to test it on your own project.

Try the new shortcuts

Let us know what you think over on the Django Forum!

September 04, 2025 03:02 PM UTC


Seth Michael Larson

Extracting NES & N64 ROMs from Zelda Collector's Edition

Gaming as a hobby is about to become much more expensive in the United States due to tariffs. I cannot recall a time in the past where a console's price has increased during its generation, and yet the Xbox Series X & S, the Nintendo Switch, and most recently the Playstation 5 have had price hikes. These are not normal times.

So here's another entry in my mini-series (#1, #2) of extracting ROMs from GameCube games, this time the “Zelda Collector's Edition” which contains 2 NES and 2 N64 Zelda titles.

This article only took so long because I was trying to actually implement the Nintendo “TGC” archive format, but it turns out that even the popular tools handling TGC can't parse the NES ROMs out of the archives included in the Zelda Collector's Edition game properly. ¯\_(ツ)_/¯

So instead I created a script which looks for NES and N64 ROM header magic strings (NES\x1A and \x80\x37\x12\x40) and used known lengths for these ROMs instead of the TGC format for framing information. So much easier!

Game Length MD5
Legend of Zelda 131088 BF8266F0FA69A5A8DAF5F23C2876A1AD
Zelda II - The Adventure of Link 262160 32308B00B9DEC4DF130C7BF703340FF3
Legend of Zelda - Ocarina of Time 33554432 CD09029EDCFB7C097AC01986A0F83D3F
Legend of Zelda - Majora's Mask 33554432 AC0751DBC23AB2EC0C3144203ACA0003

You know the drill by now: buying these games costs over $150 USD and “Zelda Collector's Edition” for the GameCube only costs ~$50 USD. Pretty good savings, especially for two of the most celebrated Zelda titles. However, the price is high enough that you might consider buying a year of “Nintendo Switch Online + Expansion Pack” if you already have the console.

I still haven't beaten “Ocarina of Time” or “Majora's Mask”, even though I know they are both masterpieces. The only Legend of Zelda games I've beaten end-to-end are “Wind Waker” and “Four Swords Adventures”, can you tell I'm a GameCube player? Let me know what your favorite Legend of Zelda title is.



Thanks for keeping RSS alive! ♥

September 04, 2025 12:00 AM UTC


Stéphane Wirtel

Utilisation d'Obsidian comme source pour Hugo

Au début juillet, dans mon précédent post Utilisation d’Obsidian pour Hugo , j’expliquais que je regardais comment utiliser Obsidian comme source pour mon blog. Jusqu’ici, j’écrivais mes posts dans VS Code ou NeoVim, mais comme Hugo repose sur du Markdown, l’idée d’utiliser directement Obsidian s’est imposée assez naturellement : tout centraliser dans un seul outil, mes notes et mes articles.

L’avantage est que j’ai toutes mes données dans un seul et unique endroit, donc je n’ai plus besoin de rechercher mes infos pour écrire mon article et l’écriture devient plus fluide, car tout est à portée de main.

September 04, 2025 12:00 AM UTC


Armin Ronacher

996

“Amazing salary, hackerhouse in SF, crazy equity. 996. Our mission is OSS.” — Gregor Zunic

“The current vibe is no drinking, no drugs, 9-9-6, […].” — Daksh Gupta

“The truth is, China’s really doing ‘007’ now—midnight to midnight, seven days a week […] if you want to build a $10 billion company, you have to work seven days a week.” — Harry Stebbings

I love work. I love working late nights, hacking on things. This week I didn’t go to sleep before midnight once. And yet…

I also love my wife and kids. I love long walks, contemplating life over good coffee, and deep, meaningful conversations. None of this would be possible if my life was defined by 12 hour days, six days a week. More importantly, a successful company is not a sprint, it’s a marathon.

And this is when this is your own company! When you devote 72 hours a week to someone else’s startup, you need to really think about that arrangement a few times. I find it highly irresponsible for a founder to promote that model. As a founder, you are not an employee, and your risks and leverage are fundamentally different.

I will always advocate for putting the time in because it is what brought me happiness. Intensity, and giving a shit about what I’m doing, will always matter to me. But you don’t measure that by the energy you put in, or the hours you’re sitting in the office, but the output you produce. Burning out on twelve-hour days, six days a week, has no prize at the end. It’s unsustainable, it shouldn’t be the standard and it sure as hell should not be seen as a positive sign of a company.

I’ve pulled many all-nighters, and I’ve enjoyed them. I still do. But they’re enjoyable in the right context, for the right reasons, and when that is a completely personal choice, not the basis of company culture.

And that all-nighter? It comes with a fucked up and unproductive morning the day after.

When someone promotes a 996 work culture, we should push back.

September 04, 2025 12:00 AM UTC

September 03, 2025


Python Morsels

The power of Python's print function

Python's print function includes abilities that are easily overlooked, even by long-time Pythonistas.

Table of contents

  1. Using multiple arguments
  2. Unpacking an iterable into print
  3. Using print instead of the string join method
  4. Customizing the sep value
  5. Printing to a file
  6. Customizing the end value
  7. Using print is a file-writing utility tool

Using multiple arguments

Python's print function can accept more than one argument:

>>> count = 4
>>> print("There are", count)
There are 4

Python's f-strings pair very nicely with the print function.

>>> count = 4
>>> total = 8
>>> print(f"{count} out of {total} is {count/total:.0%}.")
4 out of 8 is 50%.

But keep in mind that the print function also accepts multiple arguments. So if you're just putting spaces between a couple variables/strings:

>>> language = "English"
>>> print(f"Current language: {language}")

You could pass multiple arguments to print instead:

>>> language = "English"
>>> print("Current language:", language)

Python's f-strings are great, but if you just need to smoosh a few values together with spaces between them, consider passing separate arguments to print.

Unpacking an iterable into print

Python's print function doesn't just …

Read the full article: https://www.pythonmorsels.com/print-features/

September 03, 2025 11:30 PM UTC


EuroPython

EuroPython 2025 Sprints: A Weekend of Code, Collaboration, and Contributions

The EuroPython tradition of post-conference sprints came alive once again in Prague, bringing together open-source maintainers, newcomers, and curious contributors for two days of coding, learning, and collaboration.

And the results? Across all projects, over 81 pull requests were merged during the weekend 🎉. That’s dozens of fixes, improvements, and first-time contributions landing directly into Python’s ecosystem in just two days.

Hosted at WPP Campus, the sprints ran over the weekend with plenty of space, Wi-Fi, coffee, and food. The formula was simple: pick a project you care about, sit down with maintainers and peers, and work together to make the Python ecosystem a little better. Whether that meant fixing bugs, writing docs, brainstorming future work, or just asking questions, the spirit of “show up and contribute” was everywhere.

alt

What Are Sprints?

Sprints are focused coding sessions where open-source projects invite contributors to come work alongside them. For maintainers, it’s a chance to attract new contributors and get long-standing issues tackled. For participants, it’s a low-barrier way to dive into real projects, learn from experienced maintainers, and see their work make an impact right away.

At EuroPython, sprints are open to everyone—no extra ticket required. Beginners sit next to long-time core devs, and contributions range from code to documentation, design discussions, or testing. 

This Year’s Impact

Here are some highlights from the projects that sprinted this year:

Maintainers’ View 

We asked maintainers how did they like the sprints and this is what they said:

Thank you for organizing, this was my favourite sprint so far at any conference.

- Rok Mihevc, ApacheArrow

These issues were super fun to work on --- all the participants brought great stories with them, and we had great laughter seeing the results of Python in their language. 
One participant also discussed that she might make examples of these and publish in a book or a blog for Irish children to learn programming. 
Overall a 10/10 experience, would do again!

- Sahad Bazaz, Universal Python

Thanks to you and the whole EuroPython team for your work on the sprints. I know how much effort goes into putting together a sprint venue - the effort is definitely appreciated.

- Russell Keith-Magee, BeeWare 

Behind the Stats

The numbers only tell part of the story. Here are some examples of what happened during the sprints:

Looking Forward

Many projects left with PRs still in review, new contributors to nurture, and future work mapped out. If you’re a maintainer, consider bringing your project to next year’s sprints. If you’ve never contributed to open source, sprints are the perfect place to start. All it takes is curiosity and maybe a bit of coffee.

See you at the next one! 

September 03, 2025 03:51 PM UTC


Real Python

uv vs pip: Managing Python Packages and Dependencies

When it comes to Python package managers, the choice often comes down to uv vs pip. You may choose pip for out-of-the-box availability, broad compatibility, and reliable ecosystem support. In contrast, uv is worth considering if you prioritize fast installs, reproducible environments, and clean uninstall behavior, or if you want to streamline workflows for new projects.

In this tutorial, you’ll compare both tools. To keep this comparison meaningful, you’ll focus on the overlapping features, primarily package installation and dependency management. The decision table below can help you quickly choose between the two:

Use Case uv pip
You need a tool with reliable ecosystem support
You need reproducible, locked environments

Choosing the right package installer can greatly affect your workflow as a Python developer. In this tutorial, you’ll compare uv and pip, explore their overlapping features, and learn how to pick the right tool for your project’s goals.

Get Your Cheat Sheet: Click here to download the uv vs pip cheat sheet that will help you decide which tool to use.

Take the Quiz: Test your knowledge with our interactive “uv vs pip: Managing Python Packages and Dependencies” quiz. You’ll receive a score upon completion to help you track your learning progress:


Interactive Quiz

uv vs pip: Managing Python Packages and Dependencies

Test your knowledge of uv vs pip as Python package managers and learn how to pick the right tool for speed, reproducibility, and compatibility.

Metrics Comparison: uv vs pip

To help you quickly see where uv and pip differ, the table below summarizes their strengths and trade-offs in package installation and dependency management:

Metric uv pip
Out-of-the-Box Availability No Yes
Package installation speed Installs JupyterLab in 2.618 seconds Installs JupyterLab in 21.409 seconds
Reproducible installs Supports reproducible installs based on native locking Supports requirements.txt and needs pip-tools for reproducibility
Removal of transitive dependencies Yes No
Maturity and ecosystem support New and growing, adoption increasing Mature, standard tool in the Python ecosystem
Licensing MIT license MIT license
Supporting organization Astral, a private company focused on high-performance developer tools for Python Python Packaging Authority (PyPA), an official part of the Python Software Foundation (PSF)

After this quick summary, you’ll run a more detailed analysis to learn more about the intricacies of each specific metric or feature.

Note: To learn more about pip and uv in general, you can check out these tutorials:

In the following sections, you’ll explore these metrics one by one and run a few benchmarks to help you compare both tools and decide which one better suits your specific needs.

Out-of-the-Box Availability

One big reason pip remains dominant is that it ships with Python. This means that if you install Python with the official CPython installer, then you’ll have pip available out of the box and can use it to install packages with no extra step:

Shell
$ python -m pip install requests

Once you’ve installed Python, you can use pip immediately without installing additional tools. This is convenient when you don’t have the appropriate permissions to install new software on your work computer.

Note: On Ubuntu and Debian, the default Python installation often includes the python3 package, but may not include pip. If it’s missing, then you can install it by running sudo apt install python3-pip in your terminal window.

On the other hand, uv requires an extra installation step. You can install it using the standalone installer by running the command below:

Windows PowerShell
PS> powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Shell
$ curl -LsSf https://astral.sh/uv/install.sh | sh

This additional setup might not be a problem for you, but it can be a blocker if you don’t have the appropriate permissions to install apps in your working environment. Fortunately, uv has other installation options that you can use to install it in your user space.

Package Installation Speed

Here’s where uv really shines compared to pip. Written in Rust and designed for speed, uv can install packages faster than pip. This is especially true when you’re working on projects with large dependency trees.

Coming up next, you’ll see how uv and pip compare for installing packages and managing dependencies.

Setting Up the Environment

Read the full article at https://realpython.com/uv-vs-pip/ »


[ 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 ]

September 03, 2025 02:00 PM UTC


Mike Driscoll

Ep 55 – The Python Show Podcast – The Python Documentary with Paul Everitt

In this episode, we have special guest Paul Everitt on the show to discuss the new Python Documentary that was released last week. Paul is the head of developer advocacy at JetBrains and a “Python oldster”.

We chat about Python – the documentary, Paul’s start in programming as well as with Python, and much, much more!

Links

The post Ep 55 – The Python Show Podcast – The Python Documentary with Paul Everitt appeared first on Mouse Vs Python.

September 03, 2025 01:55 PM UTC


The Python Show

55 - The Python Documentary with Paul Everitt

In this episode, we have special guest Paul Everitt on the show to talk about the new Python Documentary that came our last week. Paul is the head of developer advocacy at JetBrains and a “Python oldster”.

We chat about Python - the documentary, Paul’s start in programming as well as with Python, and much, much more!

Links

September 03, 2025 12:31 PM UTC


Real Python

Quiz: uv vs pip: Managing Python Packages and Dependencies

In this quiz, you’ll test your understanding of uv vs pip: Managing Python Packages and Dependencies.

With this knowledge, you’ll be able to confidently choose between pip, the default and widely supported package installer, and uv, the newer modern project manager. You’ll dig into install speeds, locking mechanisms, dependency management, and the implications for different environments and workflows.


[ 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 ]

September 03, 2025 12:00 PM UTC


Django Weblog

Django security releases issued: 5.2.6, 5.1.12, and 4.2.24

In accordance with our security release policy, the Django team is issuing releases for Django 5.2.6, Django 5.1.12, and Django 4.2.24. These releases address the security issues detailed below. We encourage all users of Django to upgrade as soon as possible.

CVE-2025-57833: Potential SQL injection in FilteredRelation column aliases

FilteredRelation was subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().

Thanks to Eyal Gabay (EyalSec) for the report.

This issue has severity "high" according to the Django security policy.

Affected supported versions

  • Django main
  • Django 5.2
  • Django 5.1
  • Django 4.2

Resolution

Patches to resolve the issue have been applied to Django's main, 5.2, 5.1, and 4.2 branches. The patches may be obtained from the following changesets.

CVE-2025-57833: Potential SQL injection in FilteredRelation column aliases

The following releases have been issued

The PGP key ID used for this release is : 3955B19851EA96EF

General notes regarding security reporting

As always, we ask that potential security issues be reported via private email to security@djangoproject.com, and not via Django's Trac instance, nor via the Django Forum. Please see our security policies for further information.

September 03, 2025 10:36 AM UTC

September 02, 2025


Rodrigo Girão Serrão

TIL #131 – Change casing in search & replace

Today I learned you can change the casing of matched groups when doing a search & replace in VS Code with regex.

VS Code has a search & replace feature that lets you use regex to look for patterns and then reference groups in the replacement... But it lets you do something else that's really cool.

Changing casing with special sequences

When you are replacing groups, you can use special sequences to change the casing of the group you're inserting, according to the following table:

Sequence Effect
\u Uppercase the first letter
\U Uppercase the whole group
\l Lowercase the first letter
\L Lowercase the whole group

The picture below shows an example of a search & replace operation where I looked for the text “all in one go”. I enclosed that in a regex group and I'm replacing it with the pattern \U$1, which means the replacement would be the all-uppercase string “ALL IN ONE GO”:

Screenshot of VS Code previewing a search and replace operation where the special sequence \U was used to transform the text being replaced.Search and replace with \U.

Pretty nifty, right?

The same thing in Python

The module re in Python supports searching and replacing with the function re.sub but it doesn't let you do the same case-changing operations with special sequences. Instead, you have to use the fact that re.sub supports dynamic string replacements and then implement the logic yourself.

First, you can't use the string methods upper and lower directly for \U and \L; you have to grab the text from the object Match. You also have to pick the string apart to implement the \u and \l:

def all_upper(match):  # \U
    return match.group(0).upper()

def first_upper(match):  # \u
    s = match.group(0)
    return s[0].upper() + s[1:]

def all_lower(match):  # \L
    return match.group(0).lower()

def first_lower(match):  # \l
    s = match.group(0)
    return s[0].lower() + s[1:]

Here's an example:

# E.g., same behaviour as \U$0 in VS Code:
re.sub(
    "all in one go",  # pattern to search for
    all_upper,  # dynamic replacement
    "... all in one go ...",  # source text
)  # -> '... ALL IN ONE GO ...'
VS Code sequence Python function
\u first_upper
\U all_upper
\l first_lower
\L all_lower

September 02, 2025 10:51 PM UTC


PyCoder’s Weekly

Issue #697: Python Documentary, Tracking Malicious Code, Docstrings, and More (Sept. 2, 2025)

#697 – SEPTEMBER 2, 2025
View in Browser »

The PyCoder’s Weekly Logo


Python: The Documentary | An Origin Story

“This is the story of the world’s most beloved programming language: Python. What began as a side project in Amsterdam during the 1990s became the software powering artificial intelligence, data science and some of the world’s biggest companies.”
YOUTUBE.COM video

Tracking Malicious Code Execution in Python

Learn about the different ways code analysis can be done to detect malicious code in libraries, and why it is sometimes a challenging endeavor.
ARTEM GOLUBIN

Your guide to writing DAGs in Apache Airflow®

alt

Airflow’s Python based framework makes it easy to get started, but you need to set a strong foundation or risk building fragile pipelines. Join Astronomer’s webinar on September 4 to learn proven DAG writing tips to build more reliable workflows →
ASTRONOMER sponsor

How to Write Docstrings in Python

Learn to write effective Python docstrings that clearly and professionally document your code using best practices and built-in conventions.
REAL PYTHON

Quiz: How to Write Docstrings in Python

REAL PYTHON

Articles & Tutorials

5 Common Bottlenecks in pandas Workflows

Fan screaming? Laptop grinding to a halt? You’re probably running pandas on more data than your CPU wants to handle. This post breaks down five common bottlenecks in pandas (slow reads, memory-heavy joins, sluggish groupbys), typical CPU workarounds, and how a one-line cudf.pandas extension unlocks GPU acceleration—with example code and Colab links to try.
JAMIL SEMAAN • Shared by Jamil Semaan

Delta Lake: Transform pandas Prototypes Into Production

Discover how to elevate your pandas-based data workflows using delta-rs: a bridge between simple Python prototyping and robust, versioned data lakes. Learn to write, append, and time-travel through Delta tables using pandas (or Polars, Dask, DuckDB), all without Spark or JVM overhead.
KHUYEN TRAN • Shared by Khuyen Tran

Introducing an Intuitive IDE for Code and Data

alt

Positron offers an intuitive environment for exploring data, plots, apps, and connections within your IDE →
POSIT sponsor

SyntaxWarning: return in a finally Block

Returns in the finally portion of a try/except/finally block don’t necessarily behave as you might expect. As such, Python 3.14 warns you about them and they may become a syntax error in the future.
ADAM JOHNSON

pypistats.org Is Now Operated by the PSF

The pypistats.org site hosts analytics data for the Python Package Index (PyPI). For six years, pypistats.org was maintained by outside volunteers, but it has now transitioned to the PSF umbrella.
PYTHON SOFTWARE FOUNDATION

Working With JSON Data in Python

Learn how to work with JSON data in Python using the json module. Convert, read, write, and validate JSON files and handle JSON data for APIs and storage.
REAL PYTHON

Python 3.14 Preview: Lazy Annotations

Explore how Python 3.14’s lazy evaluation of annotations boosts performance, fixes chronic type hinting issues, and unlocks powerful new runtime uses.
REAL PYTHON

Quiz: Python Annotations

REAL PYTHON

Deep vs Shallow Copies in Python

Understand the difference between shallow and deep copies in Python. Learn how to duplicate objects safely using the copy module and other techniques.
REAL PYTHON course

Where to Host Your Python App

Whether it’s Django, Flask, FastAPI, or some other Python web framework, your hosting options are plenty. This guide will show you how to choose.
JEFF MORHOUS • Shared by Jeff Morhous

Expressions Are Coming to pandas

pandas 3.0 will see a new syntax introduced, bringing it closer to more modern dataframe libraries. Let’s learn about why, and how to use it
MARCO GORELLI • Shared by Marco

Quiz: Python Skill Test

Test your Python knowledge in a skill quiz with basic to advanced questions. Are you a Novice, Intermediate, Proficient, or Expert?
REAL PYTHON

Real-Time Reports With pytest

This article describes how you can use custom Pytest hooks to generate real-time reports.
CHRISTOS LIONTOS • Shared by Christos liontos

Chained Operations

Exploring chained operations and order of evaluation in python expressions
SUBSTACK.COM • Shared by Vivis Dev

Skylos: Framework-Aware Dead-Code Finder

Skylos is a Python dead-code finder focused on accuracy and speed. It’s framework-aware (Django/FastAPI/Flask) and test-aware (files/fixtures/marks), so it avoids the classic false positives. It ships an interactive CLI for selective cleanup, and includes safe LibCST codemods for unused imports/functions. There’s also an optional web UI with a confidence threshold to control noise.
GITHUB.COM/DURIANTACO • Shared by oh aaron

Projects & Code

colour: Colour Science for Python

GITHUB.COM/COLOUR-SCIENCE

alive-progress: Progress Bar With Real-Time Throughput

GITHUB.COM/RSALMEI

eyeD3: Process ID3 Tags in Mp3 Files

GITHUB.COM/NICFIT

beets: Music Library Manager

GITHUB.COM/BEETBOX

dejavu: Audio Fingerprinting and Recognition

GITHUB.COM/WORLDVEIL

Events

Weekly Real Python Office Hours Q&A (Virtual)

September 3, 2025
REALPYTHON.COM

Canberra Python Meetup

September 4, 2025
MEETUP.COM

Sydney Python User Group (SyPy)

September 4, 2025
SYPY.ORG

Python Leiden User Group

September 4, 2025
PYTHONLEIDEN.NL

PyCon Taiwan

September 6 to September 8, 2025
PYCON.ORG

PyCon Israel 2025

September 9 to September 10, 2025
PYCON.ORG.IL

PyCon India 2025

September 12 to September 16, 2025
PYCON.ORG

PyCon AU 2025

September 12 to September 17, 2025
PYCON.ORG.AU

PyCon Niger 2025

September 13 to September 16, 2025
PYCON.ORG


Happy Pythoning!
This was PyCoder’s Weekly Issue #697.
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 ]

September 02, 2025 07:30 PM UTC


Ari Lamstein

Free Course: Learn to Build Data Apps with Streamlit!

I’m thrilled to launch a hands-on, week-long email course that walks you through building, customizing, and deploying an interactive data app in Python using Streamlit. By the end of seven short lessons, you’ll have a live app exploring US demographic data—and the confidence to tackle more complex projects on your own.

Below is an image of the final app you’ll build.

Whether you’re new to Streamlit or looking to sharpen your data app skills, this free course is designed to get you building fast—with real-world data and clear guidance.

How It Works

For seven days, you’ll receive a short email with:

You’ll build the demo app locally, customize it, add new features, and deploy it with one click. If you get stuck, just hit “reply”—I’ll help you troubleshoot in real time.

Course Outline

By the end of the course you will have built, customized, and deployed your first Streamlit app. You will also gain exposure to more complex apps and ideas of what to work on next.

Ready to Dive In?

Let’s build something amazing together.

Sign up using the form below and start learning now!

September 02, 2025 04:00 PM UTC


PyCharm

The Most Popular Python Frameworks and Libraries in 2025

September 02, 2025 03:11 PM UTC

The Most Popular Python Frameworks and Libraries in 2025

Whether you’re building APIs, dashboards, or machine learning pipelines, choosing the right framework can make or break your project.

Every year, we survey thousands of Python developers to help you understand how the ecosystem is evolving, from tooling and languages to frameworks and libraries. Our insights from the State of Python 2025 offer a snapshot of what frameworks developers are using in 2025.

In this article, we’ll look at the most popular Python frameworks and libraries. While some long-standing favorites like Django and Flask remain strong, newer contenders like FastAPI are rapidly gaining ground in areas like AI, ML, and data science.

1. FastAPI

2024 usage: 38% (+9% from 2023)

Top of the table is FastAPI, a modern, high-performance web framework for building APIs with Python 3.8+. It was designed to combine Python’s type hinting, asynchronous programming, and OpenAPI standards into a single, developer-friendly package. 

Built on top of Starlette (for the web layer) and Pydantic (for data validation), FastAPI offers automatic request validation, serialization, and interactive documentation, all with minimal boilerplate.

FastAPI is ideal for teams prioritizing speed, simplicity, and standards. It’s especially popular among both web developers and data scientists.

FastAPI advantages

FastAPI disadvantages

2. Django

2024 usage: 35% (+2% from 2023)

Django once again ranks among the most popular Python frameworks for developers.

Originally built for rapid development with built-in security and structure, Django has since evolved into a full-stack toolkit. It’s trusted for everything from content-heavy websites to data science dashboards and ML-powered services.

It follows the model-template-view (MTV) pattern and comes with built-in tools for routing, data access, and user management. This allows teams to move from idea to deployment with minimal setup.

Django advantages

Django disadvantages

3. Flask

2024 usage: 34% (+1% from 2023)

Flask is one of the most popular Python frameworks for small apps, APIs, and data science dashboards. 

It is a lightweight, unopinionated web framework that gives you full control over application architecture. Flask is classified as a “microframework” because it doesn’t enforce any particular project structure or include built-in tools like ORM or form validation.

Instead, it provides a simple core and lets you add only what you need. Flask is built on top of Werkzeug (a WSGI utility library) and Jinja2 (a templating engine). It’s known for its clean syntax, intuitive routing, and flexibility.

It scales well when paired with extensions like SQLAlchemy, Flask-Login, or Flask-RESTful. 

Flask advantages

Flask disadvantages

4. Requests

2024 usage: 33% (+3% from 2023)

Requests isn’t a web framework, it’s a Python library for making HTTP requests, but its influence on the Python ecosystem is hard to overstate. It’s one of the most downloaded packages on PyPI and is used in everything from web scraping scripts to production-grade microservices.

Requests is often paired with frameworks like Flask or FastAPI to handle outbound HTTP calls. It abstracts away the complexity of raw sockets and urllib, offering a clean, Pythonic interface for sending and receiving data over the web.

Requests advantages

Requests disadvantages

5. Asyncio

2024 usage: 23% (+3% from 2023

Asyncio is Python’s native library for asynchronous programming. It underpins many modern async frameworks and enables developers to write non-blocking code using coroutines, event loops, and async/await syntax.

While not a web framework itself, Asyncio excels at handling I/O-bound tasks such as network requests and subprocesses. It’s often used behind the scenes, but remains a powerful tool for building custom async workflows or integrating with low-level protocols.

Asyncio advantages

Asyncio disadvantages

6. Django REST Framework

2024 usage: 20% (+2% from 2023)

Django REST Framework (DRF) is the most widely used extension for building APIs on top of Django. It provides a powerful, flexible toolkit for serializing data, managing permissions, and exposing RESTful endpoints – all while staying tightly integrated with Django’s core components.

DRF is especially popular in enterprise and backend-heavy applications where teams are already using Django and want to expose a clean, scalable API without switching stacks. It’s also known for its browsable API interface, which makes testing and debugging endpoints much easier during development.

Django REST Framework advantages

Django REST Framework disadvantages

Best of the rest: Frameworks 7–10

While the most popular Python frameworks dominate usage across the ecosystem, several others continue to thrive in more specialized domains. These tools may not rank as high overall, but they play important roles in backend services, data pipelines, and async systems.

FrameworkOverviewAdvantagesDisadvantages
httpx
2024 usage: 15% (+3% from 2023)
Modern HTTP client for sync and async workflowsAsync support, HTTP/2, retries, and type hintsNot a web framework, no routing or server-side features
aiohttp
2024 usage: 13% (+1% from 2023)
Async toolkit for HTTP servers and clientsASGI-ready, native WebSocket handling, and flexible middlewareLower-level than FastAPI, less structured for large apps.
Streamlit
2024 usage: 12% (+4% from 2023)
Dashboard and data app builder for data workflowsFast UI prototyping, with zero front-end knowledge requiredLimited control over layout, less suited for complex UIs.
Starlette
2024 usage: 8% (+2% from 2023)
Lightweight ASGI framework used by FastAPIExceptional performance, composable design, fine-grained routingRequires manual integration, fewer built-in conveniences

Choosing the right framework and tools

Whether you’re building a blazing-fast API with FastAPI, a full-stack CMS with Django, or a lightweight dashboard with Flask, the most popular Python web frameworks offer solutions for every use case and developer style.

Insights from the State of Python 2025 show that while Django and Flask remain strong, FastAPI is leading a new wave of async-native, type-safe development. Meanwhile, tools like Requests, Asyncio, and Django REST Framework continue to shape how Python developers build and scale modern web services.

But frameworks are only part of the equation. The right development environment can make all the difference, from faster debugging to smarter code completion and seamless framework integration.

That’s where PyCharm comes in. Whether you’re working with Django, FastAPI, Flask, or all three, PyCharm offers deep support for Python web development. This includes async debugging, REST client tools, and rich integration with popular libraries and frameworks.

Ready to build something great? Try PyCharm and see how much faster and smoother Python web development can be.

September 02, 2025 03:11 PM UTC