Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
So, what happened to pypistats?

I use this site https://www.pypistats.org/ to gauge the popularity of certain packages, but it has been down for about a month. What gives?

/r/Python
https://redd.it/1mnaren
APIException (#3 in r/FastAPI pip package flair) – Fixes Messy JSON Responses (+0.72 ms)

What My Project Does

If you’ve built anything with FastAPI, you’ve probably seen this mess:

* One endpoint returns 200 with one key structure
* Another throws an error with a completely different format
* Pydantic validation errors use yet another JSON shape
* An unhandled exception drops an HTML error page into your API, and yeah, FastAPI auto-generates Swagger, but it doesn’t correctly show error cases by default.

The frontend team cries because now they have to handle **five** different response shapes.

**With** [APIException](https://github.com/akutayural/APIException)**:**

* Both success and error responses follow the same ResponseModel schema
* Even unhandled exceptions return the same JSON format
* Swagger docs show **every** possible response (200, 400, 500…) with clear models
* Frontend devs stop asking “what does this endpoint return?” – it’s always the same
* All errors are logged by default

**Target Audience**

* FastAPI devs are tired of inconsistent response formats
* Teams that want clean, predictable Swagger docs
* Anyone who wants unhandled exceptions to return nice, readable JSON
* People who like “one format, zero surprises” between backend and frontend

**Comparison**

I benchmarked it against FastAPI’s built-in HTTPException using Locust with 200 concurrent users for 2 minutes:

|fastapi HTTPException|apiexception APIException|
|:-|:-|
|Avg Latency|2.00ms|2.72ms|
|P95|5ms|6ms|
|P99|9ms|19ms|
|Max Latency|44ms|96ms|
|RPS|609|609|

The difference is acceptable since **APIException** also **logs the exceptions**.

Also, most libraries only standardise errors. This one

/r/Python
https://redd.it/1mnf7ss
I built a tool that uses the 'ast' module to auto-generate interactive flowcharts from any Python.

Like many of you, I've often found myself deep in an unfamiliar codebase, trying to trace the logic and get a high-level view of how everything fits together. It can be a real time sink. To solve this, I built a feature into my larger project, Newton, specifically for Python developers.

What the product does

Newton is a web app that parses a Python script using the ast module and automatically generates a procedural flowchart from it. It's designed to give you an instant visual understanding of the code's architecture, control flow, and dependencies.

Here it is analyzing a 3,000+ line Python application (app.py): Gx10jXQW4AAzhH5 (1903×997)

Key Features for Developers

Automated Flowcharting: Just paste your code and it builds the graph, mapping out function definitions, loops, and conditionals.
Topic Clustering: For large scripts, an AI analyzes the graph to find higher-order concepts and emergent properties. In the screenshot, you can see it identifying things like "Application Initialization" and "User Authentication" automatically. This helps you understand what different parts of the code do conceptually.
Interactive Chat: You can select a node (like a function) or a whole Topic Cluster and ask questions about it. It's like having an agent that has already read and understood your code.

Target Audience

I built this for:

Developers who are

/r/Python
https://redd.it/1mngei8
Tilf - a Pixel Art Editor written with PySide6

Hello everyone, lately I’ve been having fun with SDL, and I wanted to try creating a small adventure video game, nothing too complex. However, to call something a proper videogame, you also need a visual component, maybe made up of a few characters and objects interacting with each other, perhaps using Pixel Art, which I personally love.

I searched online, and most of the tools that let you create even a single sprite require an account, ask for an email, are paid, or only work online. There is some open-source software that runs locally, but it can be quite complex to set up, and all I really want are a few simple tools to draw the character/object I have in mind.

Why not create an editor that only does that one thing? From past experience, I’ve loved working with Qt, especially using PySide widgets. So, here it is: I wrote it from scratch using PySide6. No installations, no configurations. You just download it to your computer and start using it right away.

There’s still a lot that could be improved, but it remains a simple and personal project, nothing demanding. I just hope it might be useful to others. It runs on Windows,

/r/Python
https://redd.it/1mno2u4
Used Django for the first time on a project and I am kind of blown away.

My wife and I had an idea for a project a few months ago that I finally got around to building (it's not ready for prime time yet so currently gated behind a mountain of Cloudflare rules). When I started on it I was using Flask for some quick hit tests of the concepts but was getting a bit frustrated extending features and how it does what it says on the tin and little else. I went down the headless CMS route for a bit playing with your standard headless Wordpress approach since I used to be pretty good in php but didn't feel like learning React or Node. Even tried Strapi which wasn't bad but not what I wanted either. Both of those CMS's were almost TOO feature rich and I felt like I was fighting them more than using them.

At a previous company we were a heavy duty Django shop (I ran ops/infra teams so we only made sure it worked at scale and all the pre-production environments worked) and I'm still friends with a bunch of people who used to write Python and worked in Django so I thought I'd give it a

/r/django
https://redd.it/1mnb4ym
I built a tool to auto-transcribe and translate China's CCTV News

What My Project Does

I created a Python tool that automatically downloads, transcribes, and translates episodes of CCTV's "Xinwen Lianbo" (新闻联播) - China's most-watched daily news program - into English subtitles.

Target Audience

Perfect for Chinese language learners who want to practice with real, current news content. The translations are faithful and contextual, making it easier to understand formal/political Chinese vocabulary.

\- Local transcription with Chinese-optimized ASR model (FunASR Paraformer)
\- OpenRouter API for translation (DeepSeek V3-0324)
\- All built with modern Python tooling (uv, typer, etc.)
\- Uses ffmpeg, yt-dlp to generate ready-made "burned" video with subtitles and processing.

Comparison

There is no project like this on GitHub (yet).

GitHub: https://github.com/piotrmaciejbednarski/cctv-xinwen-lianbo-en

/r/Python
https://redd.it/1mnp1st
eQuacks Toy Currency

eQuacks is my attempt at a toy currency. It literally has not use, but it works normally. Its backend is in Flask, so I thought I might post this here. I'll send you some of this currency if you post your eQuacks username.

Link: https://equacks.seafoodstudios.com/

Source Code: https://github.com/SeafoodStudios/eQuacks

/r/flask
https://redd.it/1mnj5z8
Tuesday Daily Thread: Advanced questions

# Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

## How it Works:

1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.

## Guidelines:

* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.

## Recommended Resources:

* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.

## Example Questions:

1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the

/r/Python
https://redd.it/1mnthov
PEP 802 – Display Syntax for the Empty Set

PEP 802 – Display Syntax for the Empty Set
https://peps.python.org/pep-0802/

# Abstract

We propose a new notation, {/}, to construct and represent the empty set. This is modelled after the corresponding mathematical symbol ‘∅’.

This complements the existing notation for empty tuples, lists, and dictionaries, which use ()[], and {} respectively.

>>> type({/})
<class 'set'>
>>> {/} == set()
True

# Motivation

Sets are currently the only built-in collection type that have a display syntax, but no notation to express an empty collection. The Python Language Reference notes this, stating:

>An empty set cannot be constructed with {}; this literal constructs an empty dictionary.

This can be confusing for beginners, especially those coming to the language from a scientific or mathematical background, where sets may be in more common use than dictionaries or maps.

A syntax notation for the empty set has the important benefit of not requiring a name lookup (unlike set()). {/} will always have a consistent meaning, improving teachability of core concepts to beginners. For example, users must be careful not to use set as a local variable name, as doing so prevents constructing new sets. This can be frustrating as beginners may not know how to recover the `set` type if they have overriden the name.

/r/Python
https://redd.it/1mnuan1
I built a tiny tool to convert Pydantic models to TypeScript. What do you think?

At work we use FastAPI and Next.js, and I often need to turn Pydantic models into TypeScript for the frontend. Doing it by hand every time was boring, slow, and easy to mess up so I built a small app to do it for me.

* Paste your Pydantic models/enums, get clean TypeScript interfaces/types instantly.
* Runs 100% in your browser (no server, no data saved)
* One-click copy or download a .ts file

# What My Project Does

My project is a simple website that converts your Python Pydantic models into clean TypeScript code. You just paste your Pydantic code, and it instantly gives you the TypeScript version. It all happens right in your browser, so your code is safe and never saved. This saves you from having to manually type out all the interfaces, which is boring and easy to mess up.

# Target Audience

This is for developers who use FastAPI on the backend and TypeScript (with frameworks like Next.js or React) on the frontend. It's a professional tool meant to be used in real projects to keep the backend and frontend in sync.

# Comparison

There are other tools out there, but they usually require you to install them and use your computer's command line. My tool is different because it's

/r/Python
https://redd.it/1mo20uc
🚀 Introducing Beautypy – Open-Source Django UI Component Library

Hey Django devs! 👋

I’ve been working on an open-source project called Beautypy — a Django UI component library designed to help developers quickly add beautiful, reusable, and customizable UI elements without wasting hours on CSS and HTML.

# 📌 What is Beautypy?

Beautypy is:

A growing collection of ready-to-use Django template components
Styled with modern design principles out of the box (now using Bootstrap for compatibility)
Includes reusable template tags like:
{% Button label="Submit" type="submit" %} {% Alert type="success" message="Form submitted successfully!" %} {% ContactForm %}
Focused on developer speed and clean UI

# 💡 Why Use Beautypy?

Saves time – No need to hand-code repetitive HTML + CSS
Pre-styled components – Works instantly with Bootstrap’s responsive grid
Easier maintainability – Centralized templates make UI changes site-wide in seconds
Consistency – Every button, form, and alert matches your site’s style
Customizable – Override templates or styles to fit your brand easily
Zero JavaScript dependency for basics – Just Django templates and Bootstrap

# 📦 Installation

Install Beautypy from PyPI:

pip install beautypy


📄 Docs: [
https://pypi.org/project/beautypy/](https://pypi.org/project/beautypy/)

# 🌐 Live Demo

Want to see Beautypy in action?
🔗 Official Demo Website: [
beautypy.pythonanywhere.com](https://beautypy.pythonanywhere.com)

# 🤝 How You Can Help

Test it in

/r/django
https://redd.it/1mo3i47
Type hints for variable first mentions - yes/no/sometimes(when?)?

I'm new to python from a java background. Python is so easy when you are writing new code or are reading code you wrote in the last hour (e.g. during an interview).

Reading some code I wrote last week in a Colab notebook for a class notebook using some API that I'm learning (e.g. Word2Vec), it's not so easy. I don't know what operations I can perform on this variable I added but didn't name with enough information to trivially determine its type.

Java is so explicit with type declarations it makes you cry, but I'm seeing the dark side of dynamic typing.

One possible solution is to use type hints anywhere the type info is welcome (subjective I know). But is there any kind of best practice which maybe says that you should not do it to the point it just crowds your code and makes you hate yourself the way Java does?

(EDIT: yes I know modern java has var but the reality is it's in very few codebases because of version fatigue. Same reason we don't see much C23 or C++23)

/r/Python
https://redd.it/1mntk24
structlog-journald, attach extra info to jogs and filter logs by it

- What my project does: In a multi-tenant system, logs from various tenants are often mixed, making difficult to debug. This library bridges structlog and journald, to allow to attach extra info (like tenant ID) when writing logs. When we view logs via journalctl, we can filter by that tenant ID.
- Target audience: Python developers who often debug a system of many concurent operations running.
- Source code: https://github.com/hongquan/structlog-journald
- Manual: https://structlog-journald.readthedocs.io/en/latest/advanced.html

/r/Python
https://redd.it/1mo8ypj