1102
Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels
How much typing is Pythonic?
I mostly stopped writing Python right around when mypy was getting going. Coming back after a few years mostly using Typescript and Rust, I'm finding certain things more difficult to express than I expected, like "this argument can be anything so long as it's hashable," or "this instance method is generic in one of its arguments and return value."
Am I overthinking it? Is
if not hasattr(arg, "hash"):
raise ValueError("argument needs to be hashashable")
the one preferably obvious right way to do it?
ETA: I believe my specific problem is solved with TypeVar("T", bound=typing.Hashable), but the larger question still stands.
/r/Python
https://redd.it/1pkt94z
RenderCV v2.5: Write your CV in YAML, version control it, get pixel-perfect PDFs
TLDR: Check out github.com/rendercv/rendercv
Been a while since the last update here. RenderCV has gotten much better, much more robust, and it's still actively maintained.
## The idea
Separate your content from how it looks. Write what you've done, and let the tool handle typography.
cv:
name: John Doe
email: john@example.com
sections:
experience:
- company: Anthropic
position: ML Engineer
start_date: 2023-01
highlights:
- Built large language models
- Deployed inference pipelines at scale
rendercv render John_Doe_CV.yaml, get a pixel-perfect PDF. Consistent spacing. Aligned columns. Nothing out of place. Ever.git diff your CV changes. Review them in PRs. Your CV history is your commit history. Use LLMs to help write and refine your content.
I kept bouncing between GUI frameworks and Electron, so I tried building something in between
I’ve been trying to build small desktop apps in Python for a while and honestly it was kind of frustrating
Every time I started something new, I ended up in the same place. Either I was fighting with a GUI framework that felt heavy and awkward, or I went with Electron and suddenly a tiny app turned into a huge bundle
What really annoyed me was the result. Apps were big, startup felt slow, and doing anything native always felt harder than it should be. Especially from Python
Sometimes I actually got things working in Python, but it was slow… like, slow as fk. And once native stuff got involved, everything became even more messy.
After going in circles like that for a while, I just stopped looking for the “right” tool and started experimenting on my own. That experiment slowly turned into a small project called TauPy
What surprised me most wasn’t even the tech side, but how it felt to work with it. I can tweak Python code and the window reacts almost immediately. No full rebuilds, no waiting forever.
Starting the app feels fast too. More like running a script than launching a full desktop framework.
I’m still very much figuring out where this
/r/Python
https://redd.it/1pl76qm
D HTTP Anomaly Detection Research ?
I recently worked on a side project of anomaly detection of Malicious HTTP Requests by training only on Benign Samples - with the idea of making a firewall robust against zero day exploits, It involved working on
1. A NLP architecture to learn the semantics and structure of a safe HTTP Request and differ it from malicious requests
2. Re Training the Model on incoming safe data to improve perfomance
3. Domain Generalization across websites not in the test data.
What are the adjacent research areas/papers i can work upon and explore to improve this project ?
and what is the current SOTA of this field ?
/r/MachineLearning
https://redd.it/1pktkx6
D On the essence of the diffusion model
Hi all, I am learning about diffusion models and want to understand their essence rather than just applications. My initial understanding is that diffusion models can generate a series of new data starting from isotropic Gaussian noise.
I noticed that some instructions describe the inference of the diffusion model as a denoising process, which can be represented as a set of regression tasks. However, I still find it confusing. I want to understand the essence of the diffusion model, but its derivation is rather mathematically heavy. The more abstract summaries would be helpful. Thanks in advance.
/r/MachineLearning
https://redd.it/1pkuoay
Open-sourcing my “boring auth” defaults for FastAPI services
What My Project Does
I bundled the auth-related parts we kept re-implementing in FastAPI services into an open-source package so auth stays “boring” (predictable defaults, fewer footguns).
from svc_infra.api.fastapi.auth.add import add_auth_users
add_auth_users(app)
Friday Daily Thread: r/Python Meta and Free-Talk Fridays
# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️
Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!
## How it Works:
1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.
## Guidelines:
All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.
## Example Topics:
1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.
Let's keep the conversation going. Happy discussing! 🌟
/r/Python
https://redd.it/1pkd3is
Django RAPID Architecture, a guide to structuring Django projects
https://www.django-rapid-architecture.org/
/r/django
https://redd.it/1pko7q6
BezBartek/django-db-views: Creating automatic migrations for Views models witch working reverse and full command options like in normal makemigrations
https://github.com/BezBartek/django-db-views
/r/django
https://redd.it/1pjvsut
Just had the weirdest bug today
My plugin loading system started to hang indefinitely in all my tests randomly during one of my refactors. After a lot of painful stepping through I finally found out the bug was in fact cause by aiohttp which was hanging indefinitely on import for only God knows why. Rebooted my pc and it fixed itself and i couldn't replicate the bug since. Im on python 3.14 with the latest version of aiohttp anyone else had something similar to this happen to them recently? Trying to figure out the cause so it doesn't make my tests shit themselves again wasting debug time
/r/Python
https://redd.it/1pk5hnv
Python tool to quickly create a nicely animated .gif out of an .stl for communicating ideas wout cad
* **What My Project Does**
takes a 3d model in stl and renders a quick isometric animation about two axes then does a crazy undo thing and loops all nice, just run, select .stl file and boom
* **Target Audience** (e.g., Is it meant for production, just a toy project, etc.
anyone working with 3d models that want to quickly send a visual to a colleague / friend / investor etc.
* **Comparison** (A brief comparison explaining how it differs from existing alternatives.)
I googled around for 5 minutes and it didn't exist in the form I imagined where it just selects a file and plops out a perfectly animated and scaled isometric rotating gif that loops all aesthetically perfectly and yes I did use claude but this is art okay
[https://github.com/adamdevmedia/stl2gif](https://github.com/adamdevmedia/stl2gif)
/r/Python
https://redd.it/1pjklha
What if groups are not enough for authorization?
In many cases, just a group doesn't give enough information to decide what a user can do or see.
Let's say I'm creating a site for car sharing. For the sake of simplicity, let's say we have administrators, car owners, and drivers. Administrators can do everything, so I'll just ignore those for now.
For a given car, we have different things that various users can do, and that depends on the relation between the user and the specific car/reservation, for example:
\- only the person who owns the car can edit the schedule for sharing it, and assign drivers to free slots in the schedule
\- everyone can request to reserve a slot in the schedule
\- only the owner of the car and the driver who made a reservation, can cancel that reservation
So we need to know the group someone is in, AND whether they are the owner of the current car, or the driver for the current reservation, etc. That makes the standard permissions framework a bit useless.
In the past I've use django-rules for this, but that seems to be poorly maintained. I was wondering how people in general implement this, do you extend the permissions framework somehow? Is there a best practice
/r/django
https://redd.it/1pj8ew3
R How does one get "invited talks" or any "talk" for that matter for a published work?
The title --- I see PhD students get invited to present their recently published (or even arXiv based) work here and there. How does that work? Do people just reach out to you or do you reach out to people looking for speakers?
In case of the latter, how and where do you find such people? In case of the former, how to get noticed (without best paper awards and chunky publication history)?
P.S. If any of y'all looking for speakers, I'm doing some causal ML stuff.
/r/MachineLearning
https://redd.it/1pjbo1m
Howto: File Uploads with Django & DRF
https://django.wtf/blog/file-uploads-with-django-drf/
/r/django
https://redd.it/1pj99hk
blank page on python flask project
Im working on a web application with python flask, html, css, bootstrap and sqlite db. I have created the base.html file (instead of index), base_guest.html (extends base) and the login_fron.html (extends base_guest) which is for the login. Even though everything seems to be fine everytime i try to run 127.0.0.1:5000/login nothing appears on my vs code terminal or the web page and when i press ctrl + u to see the source of the page nothing appears on the source. Does anyone have an idea what coulod be wrong. ( "* Serving Flask app 'app'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 167-011-435" thats the only thing that appears on my vs code even when i run the web page)
base.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tasks {% block title %}{% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
</head>
<body>
<div class="container">
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a
/r/flask
https://redd.it/1pj5fpr
DRF Auth Kit: A Complete Authentication Solution for Django REST Framework
Hi everyone,
I’d like to (re)introduce **DRF Auth Kit** — a comprehensive authentication package for Django REST Framework.
If you’re looking for an auth solution that provides:
* **Modern, secure authentication**: Read-only JWT cookie auth (also supports DRF Token and custom auth methods)
* **Full user authentication flow**: Sign up, sign in, password reset, change password, etc., with easy customization of views and serializers
* **Broad Django support**: Compatible with Django 4.2 through the latest 6.0
* **Social & OAuth2 login**: 50+ providers (Google, GitHub, and more) via `django-allauth`
* **Multi-factor authentication (MFA)**: Email, authenticator apps, and backup codes
* **Full typing support**: Pyright and MyPy compatible
* **Internationalization**: 57+ languages including English, Spanish, French, German, Chinese, Japanese, Korean, Vietnamese, and more
* **Accurate OpenAPI schemas**: Ideal for schema-to-code tools on the frontend
* **Highly customizable components** without breaking core functionality
# Why DRF Auth Kit?
Inspired by `django-allauth`, `dj-rest-auth`, and `django-trench`, but designed to address their common pain points:
* Correct and complete OpenAPI schemas
* End-to-end type safety
* No manual schema fixes required
* Easy customization that stays maintainable
# Perfect for:
* Teams that need reliable, accurate API documentation
* Projects that require type-safe authentication
* Developers tired of patching broken auth schemas
* Anyone who values clean, well-documented code
# How to use:
`pip install drf-auth-kit[all] # Includes MFA
/r/django
https://redd.it/1plg3be
PyPulsar — a Python-based Electron-like framework for desktop apps
# What My Project Does
**PyPulsar** is an open-source framework for building **cross-platform desktop applications** using **Python for application logic** and **HTML/CSS/JavaScript for the UI**.
It provides an Electron-inspired architecture where a Python “main” process manages the application lifecycle and communicates with a WebView-based renderer responsible for displaying the frontend.
The goal is to make it easy for Python developers to create modern desktop applications without introducing Node.js into the stack.
Repository (early-stage / WIP):
[https://github.com/dannyx-hub/PyPulsar](https://github.com/dannyx-hub/PyPulsar)
# Target Audience
PyPulsar is currently an **early-stage project** and is **not production-ready** yet.
It is primarily intended for:
* Python developers who want to build desktop apps using web technologies
* Hobbyists and open-source contributors interested in framework design
* Developers exploring alternatives to Electron with a Python-first approach
At this stage, the focus is on **architecture, API design, and experimentation**, rather than stability or long-term support guarantees.
# Comparison
PyPulsar is inspired by Electron but differs in several key ways:
* **Electron**: Uses Node.js for the main process and bundles Chromium. **PyPulsar** uses Python as the main runtime and relies on system WebViews instead of shipping a full browser.
* **Tauri**: Focuses on a Rust backend and a minimal binary size. **PyPulsar** targets Python developers who prefer Python over Rust and want a more hackable, scriptable
/r/Python
https://redd.it/1pl2qso
VSCode extension that supports jumping to partial definition?
Hello guys, since 6.0 introduced partials, I've been looking for a VSCode extension that support jumping to the partial definition when you press CTRL + click. I've tried both https://marketplace.visualstudio.com/items?itemName=batisteo.vscode-django and https://marketplace.visualstudio.com/items?itemName=almahdi.code-django and I have even submited requests for this feature but these extensions have not been updated in a long tine. Do you guys have any solution for this? These extensions both support "jump to template". What I mean is for example, if you have this line:
return render(request, 'index.html#somepartial', {})
CTRL + clicking the template name would take you to the partial defition. Right now
return render(request, 'index.html', {})
works but adding the '#somepartial' breaks the "jump to template" functionality.
/r/django
https://redd.it/1pl6stj
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
# Weekly Thread: Resource Request and Sharing 📚
Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!
## How it Works:
1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.
## Guidelines:
Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.
## Example Shares:
1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.
## Example Requests:
1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.
Share the knowledge, enrich the community. Happy learning! 🌟
/r/Python
https://redd.it/1pl76y8
Open-source Flask projects to contribute to?
I’ve been working with Flask for two years, mostly on my own projects, but now I’d like to join a larger project and contribute to the open-source ecosystem.
Do you maintain or know of any projects where I could get some practice?
/r/flask
https://redd.it/1pkajq1
D Interview preparation for research scientist/engineer or Member of Technical staff position for frontier labs
How do people prepare for interviews at frontier labs for research oriented positions or member of techncial staff positions? I am particularly interested in as someone interested in post-training, reinforcement learning, finetuning, etc.
1. How do you prepare for research aspect of things
2. How do you prepare for technical parts (coding, leetcode, system design etc)
/r/MachineLearning
https://redd.it/1pkhblb
Manage database sessionsor connections
I have API service using
(Python + MYSQL + SQLAlchemy + Celery workers)
Application starting to see more traffic.
I want to make sure I avoid connection leaks, timeouts, or overloading the DB.
1. How to monitor the connection count properly ?
2. Should every request open/close a DB connection or should I rely on a global connection pool ?
3. Rule of thumb for max connections vs DB instance size ?
Any references , appreciated Thanks
/r/flask
https://redd.it/1pkjdeo
Sveltekit authentication using better-auth and Django
I've been working on a side SaaS project for a couple of days and have reached a point where I'm satisfied with the backend and thinking on creating a Sveltekit front end. I've read a bit on how to setup authentication and a lot of resources mentioned better-auth which offers out of the box support for Sveltekit. However, I went through the documentation and it seems intended to be used as its own authentication backend/frontend, where better-auth saves user credentials and sessions in its own database separate from Django. I spent some time thinking about it and consulted stack overflow as well as ChatGPT and was recommended the following approach:
- Better auth handles all authentication and user registration, and saves credentials in its own database
- Sveltekit receives session token from better-auth as well as a JWT token
- Sveltekit uses the token to add an Authorization header to request made to Django
- Django decodes the JWT token, extracts the user making the request from the token claims, and authorizes the request
I'm not sure if this approach would be valid, since this would mean either having the credentials saved on both the Django db and authentication db/table, or the SaaS users would
/r/djangolearning
https://redd.it/1pkne5h
Massive Excel exportation problem
I was assigned to solve a problem with a report. The problem is exporting massive amounts of data without overloading the container's CPU.
My solution was to create a streaming Excel exporter, processing and writing all the data in chunks. The details of my implementation were, first, to use the iterator() method of Django QuerySet to query the data in chunks from the database and then pass it to Pandas Dataframe, apply some transformations and overwrite a temporary file to complete all the data in the report, and finally upload it to a bucket.
This solution works very well, but I would like to know if you know of a better way to solve it.
/r/django
https://redd.it/1pkfzr4
Just created a css utility class generator for my admin panel
Features:
* Generates a minified file for CSS utility classes.
* Generates a guide file for quick explaination and for feeding into AI models with as few tokens as possible.
* Compresses with brotli 11 because the main file is massive
[https://github.com/flicksell/css-utils-generator/](https://github.com/flicksell/css-utils-generator/)
Note - since it's something I made for my project, I don't imagine many people being able to use it as-is, but I think this could be an inspiration for something you might build (or vibe code) yourself in an opinionated manner.
/r/Python
https://redd.it/1pk6ij4
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
# Weekly Thread: Professional Use, Jobs, and Education 🏢
Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.
---
## How it Works:
1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.
---
## Guidelines:
- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.
---
## Example Topics:
1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?
---
Let's help each other grow in our careers and education. Happy discussing! 🌟
/r/Python
https://redd.it/1pjisyw
This one liner bug fix took 3 hours to identify and understand.
Yesterday I lost two full hours of my life to the most infuriating Django + Celery bug in a freelanced code base.
Issue:
Orders were being created fine.
Related OrderItems (created in a post_save signal) were saving correctly.
The confirmation email Celery task was being sent.
But inside the task, order.items.all() was empty.
Every. Single. Time.
I checked everything:
Signals were connected.
Transaction was committing.
No database replication lag.
Task was running on the same DB.
Even added time.sleep(5) in the task, still no items.
I was one step away from rewriting the whole thing with a service layer and explicit item creation inside the view. Then I looked at the code again:
def create_order(data):
with transaction.atomic():
order = Order.objects.create(**data)
transaction.on_commit(
lambda: send_order_confirmation.delay(order.id)
)
return order
Did you get it?
Turns out this is the classic Python closure-in-loop gotcha, but inside a single function.
The lambda captures the name order, not the value.
By the time the on_commit callback runs (after the transaction
/r/django
https://redd.it/1pjre47
How to make long dropdown options break into multiple lines in Django?
Hi everyone,
I’m facing an issue in my Django project with a dropdown (select field). Some of the options have long text, but instead of wrapping to the next line, the text gets cut off. I’ve already tried several approaches, but none of them worked due to Django’s select widget behavior, which doesn’t seem to allow modifying this easily.
Has anyone dealt with this before or knows a CSS/HTML workaround that works for Django forms or admin? Or maybe an alternative would be to show the full content when hovering over the option?
Thanks in advance!
/r/djangolearning
https://redd.it/1pd3uto
django intertia might be the biggest game changer
Have been using it for a bit now when before I had a nextjs app and was using django as our api backend
We ended up trashing the nextjs app and brought it over to inertia so django can be the beautiful monolith it is and its been flawless
thats all. Had to share
/r/django
https://redd.it/1pjapxb
Django-q problem
I am making a sort of reminder api with django it would take a message ,a time to start ,the reminder , an interval and the number of times the message should be sent, im using django-q to handle scheduling and I want to output a json payload that would contain the messages the with their timestamps for each time the message was called
/r/djangolearning
https://redd.it/1pia0xd