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
[P] Interactive Advanced Llama Logit Lens

/r/MachineLearning
https://redd.it/1p4akjr
What could I have done better here?

Hi, I'm pretty new to Python, and actual scripting in general, and I just wanted to ask if I could have done anything better here. Any critiques?

import time
import colorama
from colorama import Fore, Style

color = 'WHITE'
colorvar2 = 'WHITE'

#Reset colors
print(Style.RESETALL)

#Get current directory (for debugging)
#print(os.getcwd())

#Startup message
print("Welcome to the ASCII art reader. Please set the path to your ASCII art below.")

#Bold text
print(Style.BRIGHT)

#User-defined file path
path = input(
Fore.BLUE + 'Please input the file path to your ASCII art: ')
color = input('Please input your desired color (default: white): ' + Style.RESET
ALL)

#If no ASCII art path specified
if not path:
print(Fore.RED +

/r/Python
https://redd.it/1p4ffmh
Air gapped app

How does one prepare an air gapped app version of the Django project ?

are there tools to wrap frontend and backend in Docker and orchestrate this on a cloud ?

/r/django
https://redd.it/1p4fs71
Python Mutable Defaults or the Second Thing I Hate Most About Python

TLDR: Don’t use default values for your annotated class attributes unless you explicitly state they are a ClassVar so you know what you’re doing. Unless your working with Pydantic models. It creates deep copies of the models.
I also created a demo flake8 linter for it: https://github.com/akhal3d96/flake8-explicitclassvar/ Please check it out and let me know what you think.

I run into a very annoying bug and it turns out it was Python quirky way of defining instance and class variables in the class body. I documented these edge cases here: https://blog.ahmedayoub.com/posts/python-mutable-defaults/

But basically this sums it up:

class Members:
number: int = 0

class FooBar:
members: Members = Members()


A = FooBar()
B = FooBar()

A.members.number = 1
B.members.number = 2

# What you expect:
print(A.members.number) # 1
print(B.members.number) # 2




/r/Python
https://redd.it/1p469fk
The Labyrinth of Tech Careers: The Significance of Your Developer Portal
https://mappen.ai/blog/the-labyrinth-of-tech-careers-the-significance-of-your-developer-portal

/r/django
https://redd.it/1p4jg3x
I built a backend-only data analysis tool using Django.

I have focused heavily on security, ensuring the tool is safe against file upload vulnerabilities and common threats like XSS.

Feel free to review or audit the code. If you find any security flaws or bugs, please let me know in the comments. The project is open source, so you are welcome to fork and modify it. I would appreciate any feedback or suggestions to help me improve my future projects.

Repository Link: https://github.com/saa-999/djangolytics



/r/django
https://redd.it/1p4mn24
Announcing Spikard: TypeScript + Ruby + Rust + WASM)

Hi Peeps,

I'm announcing [Spikard](https://github.com/Goldziher/spikard) v0.1.0 - a high-performance API toolkit built in Rust with first-class Python bindings. Write REST APIs, JSON-RPC services, or Protobuf-based applications in Python with the performance of Rust, without leaving the Python ecosystem.

## Why Another Framework?

**TL;DR: One toolkit, multiple languages, consistent behavior, Rust performance.**

I built Spikard because I was tired of:
- Rewriting the same API logic in different frameworks across microservices
- Different validation behavior between Python, TypeScript, and Ruby services
- Compromising on performance when using Python for APIs
- Learning a new framework's quirks for each language

Spikard provides **one consistent API** across languages. Same middleware stack, same validation engine, same correctness guarantees. Write Python for your ML API, TypeScript for your frontend BFF, Ruby for legacy integration, or Rust when you need maximum performance—all using the same patterns.

## Quick Example

```python
from spikard import Spikard, Request, Response
from msgspec import Struct

app = Spikard()

class User(Struct):
name: str
email: str
age: int

@app.post("/users")
async def create_user(req: Request[User]) -> Response[User]:
user = req.body # Already validated and parsed
# Save to database...
return Response(user, status=201)

@app.get("/users/{user_id}")
async def get_user(user_id: int) -> Response[User]:
# Path params

/r/Python
https://redd.it/1p4m5be
Interactive visualisations of the floodfill algorithm in Python and PyScript

I've always liked graph-related algorithms and I wanted to try my hand at writing an article with interactive demos, so I decided to write an article that teaches how to implement and use the floodfill algorithm.

This article teaches you how to implement and use the floodfill algorithm and includes interactive demos to:
- use floodfill to colour regions in an image
- step through the general floodfill algorithm step by step, with annotations of what the algorithm is doing
- applying floodfill in a grid with obstacles to see how the starting point affects the process
- use floodfill to count the number of disconnected regions in a grid
- use a modified version of floodfill to simulate the fluid spreading over a surface with obstacles

The interactive demos were created using (mostly) PyScript, since I also wanted to give it a try.

I know the internet can be relentless but I'm really looking forward to everyone's comments and suggestions, since I love interactive articles and I hope to be able to create more of these in the future.

Happy reading and let me know what you think!

The article: https://mathspp.com/blog/floodfill-algorithm-in-python

/r/Python
https://redd.it/1p4nn86
A Django + WebRTC chat app... (repo + demo inside)

Hey everyone,

This is nothing special. I know there are plenty of real-time chat apps out there. I just wanted to try building one myself and get better with Django Channels and WebRTC audio.

I ended up putting together a small chat app using Django, Channels, Redis, React, and a basic WebRTC audio huddle using STUN/TURN from Twilio’s free tier. Getting the audio signalling to behave properly was honestly the most interesting part for me.

The whole thing is open source and super easy to run locally. You can also try the demo if you want.

GitHub: [https://github.com/naveedkhan1998/realtime-chat-app](https://github.com/naveedkhan1998/realtime-chat-app)
Demo: [https://chat.mnaveedk.com/](https://chat.mnaveedk.com/)

The code is basically a mix of my old snippets, manual architecture I’ve built up over time, and some vibe coding, where I used tools to speed things up. I mainly use VSCode Copilot (multiple models in there, including the new Gemini 3, which is decent for UI stuff) and Codex CLI. These are the only two things I’m actually subscribed to, so that’s pretty much my entire toolset. I tried my best to review everything important manually, so please let me know if you find any glaringly stupid stuff in there.

# What I’d like feedback on

* Does my Channels and consumer structure make

/r/django
https://redd.it/1p4v9w3
D ML conferences need to learn from AISTATS (Rant/Discussion)

Quick rant. As many have noticed and experienced, the quality of reviews at large conferences such as ICLR, ICML. AAAI, NIPS, has generally been very inconsistent with several people getting low quality or even AI written reviews. While this is not too shocking given the number of submissions and lack of reviewers changes need to be made.

Based on my experience and a general consensus by other researchers, AISTATS is the ML conference with the highest quality of reviews. Their approach to reviewing makes a lot more sense and is more similar to other scientific fields and i believe the other ML conferences should learn from them.

For example:
1) they dont allow for any LLMs when writing reviews and they flag any reviews that have even a small chance of being AI written (i think everyone should do this)
2) they follow a structured reviewing format making it much easier to compare the different reviewers points.
3) Reviews are typically shorter and focus on key concerns making it easier to pin point what you should adress.

While AISTATS also isn't perfect in my experience it feels less "random" than other venues and usually I'm sure the reviewers have actually read my work. Their misunderstandingd

/r/MachineLearning
https://redd.it/1p4tme7
Best platform for deploying Django apps in 2025

Haven't deployed a Django app in a long time. I think my last one was deployed using Heroku back when it was very easy to use. I think that is not the case anymore.

What are the best options for 2025/2026?

/r/django
https://redd.it/1p5357w
D How do you create clean graphics that you'd find in conference papers, journals and textbooks (like model architecture, flowcharts, plots, tables etc.)?

just curious. I've been using draw.io for model architecture, seaborn for plots and basic latex for tables but they feel rough around the edges when I see papers at conferences and journals like ICLR, CVPR, IJCV, TPAMI etc, and computer vision textbooks.

FYI I'm starting my graduate studies, so would like to know how I can up my graphics and visuals game!

/r/MachineLearning
https://redd.it/1p4t8l8
Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas 💡

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

/r/Python
https://redd.it/1p5239o
Adding Vite to Django for a Modern Front End with React and Tailwind CSS (Part of "Modern JavaScript for Django Developers")

Hey folks! Author of the "Modern JavaScript for Django Developers" series here. I'm back with a fresh new guide.

When I first wrote about using modern JavaScript with Django back in 2020, the state-of-the-art in terms of tooling was Webpack and Babel. But—as we know well—the JavaScript world doesn't stay still for long.

About a year ago, I started using Vite as a replacement for Webpack on all my projects, and I'm super happy with the change. It's faster, easier to set up, and lets you do some very nice things like auto-refresh your app when JS/CSS changes.

I've finally taken the time to revisit my "Modern JavaScript for Django Developers" series and update it with what I feel is the best front end setup for Django projects in 2025. There are three parts to this update:

* A brand new guide: [Adding Vite to Django, so you can use Modern JavaScript, React, and Tailwind CSS](https://www.saaspegasus.com/guides/modern-javascript-for-django-developers/integrating-javascript-pipeline-vite/)
* A video walkthrough: [Setting up a Django project with Vite, React, and Tailwind CSS](https://youtu.be/GztJ1h6ZXA0)
* An open-source repository with the finished product you can use to start a new project: [https://github.com/saaspegasus/django-vite-tailwind-starter/](https://github.com/saaspegasus/django-vite-tailwind-starter/)

Hope this is useful, and let me know if you have any questions or feedback!

/r/django
https://redd.it/1p5g975
GeoPolars is unblocked and moving forward

TL;DR: GeoPolars is a similar extension of Polars as GeoPandas is from Pandas. It was blocked by upstream issues on Polars side, but those have now been resolved. Development is restarting!

GeoPolars is a high-performance library designed to extend the Polars DataFrame library for use with geospatial data. Written in Rust with Python bindings, it utilizes the GeoArrow specification for its internal memory model to enable efficient, multithreaded spatial processing. By leveraging the speed of Polars and the zero-copy capabilities of Arrow, GeoPolars aims to provide a significantly faster alternative to existing tools like GeoPandas, though it is currently considered a prototype.

Development on the project is officially resuming after a period of inactivity caused by upstream technical blockers. The project was previously stalled waiting for Polars to support "Extension Types," a feature necessary to persist geometry type information and Coordinate Reference System (CRS) metadata within the DataFrames. With the Polars team now actively implementing support for these extension types, the primary hurdle has been removed, allowing the maintainers to revitalize the project and move toward a functional implementation.

The immediate roadmap focuses on establishing a stable core architecture before expanding functionality. Short-term goals include implementing Arrow data conversion between the underlying Rust

/r/Python
https://redd.it/1p5dtvn
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/1p5xih6
P Feedback/Usage of SAM (Segment Anything)

Hi folks!

I'm one of the maintainers of Pixeltable and we are looking to provide a built-in support for SAM (Segment Anything) and I'd love to chat with people who are using it on a daily/weekly basis and what their workflows look like.

Pixeltable is quite unique in the way that we can provide an API/Dataframe/Engine to manipulate video/frames/arrays/json as first-class data types to work with among other things which makes it very unique programmatically to work with SAM outputs/masks.

Feel free to reply here/DM me or others :)

Thanks and really appreciated!

/r/MachineLearning
https://redd.it/1p5xmhw
CORS Error in my Flask | React web app



Hey, everyone, how's it going?



I'm getting a CORS error in a web application I'm developing for my portfolio.

I'm trying to use CORS in my <app.py> and in my endpoint, but the error persists.
I think it is a simple error, but I am trying several ways to solve it, without success!



Right now, I have this line in my <app.py>, above my blueprint.



# imports
from flaskcors import CORS

def create
app():

app = Flask(name)

...

CORS(app)

...

if name == 'main:

...


PS: I read something about the possibility of it being a Swagger-related error, but I don't know if that makes sense. 











/r/flask
https://redd.it/1p5j53r
MovieLite: A MoviePy alternative for video editing that is up to 4x faster

Hi r/Python,

I love the simplicity of MoviePy, but it often becomes very slow when doing complex things like resizing or mixing multiple videos. So, I built MovieLite.

This started as a module inside a personal project where I had to migrate away from MoviePy due to performance bottlenecks. I decided to extract the code into its own library to help others with similar issues. It is currently in early alpha, but stable enough for my internal use cases.

Repo: https://github.com/francozanardi/movielite

### What My Project Does

MovieLite is a library for programmatic video editing (cutting, concatenating, text overlays, effects). It delegates I/O to FFmpeg but handles pixel processing in Python.

It is designed to be CPU Optimized using Numba to speed up pixel-heavy operations. Note that it is not GPU optimized and currently only supports exporting to MP4 (h264).

### Target Audience

This is for Python Developers doing backend video automation who find MoviePy too slow for production. It is not a full-featured video editor replacement yet, but a faster tool for the most common automation tasks.

### Comparison & Benchmarks

The main difference is performance. Here are real benchmarks comparing MovieLite vs. MoviePy (v2.x) on a 1280x720 video at 30fps.

These tests were run using 1 single process, and the

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