Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels
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/1lua5dh
Flask Error
from flask import Flask
app = Flask(name)
@app.route("/")
def home():
return "Offline Flask is working!"
if name == "main":
print("Starting Flask server...")
app.run(debug=True)
after running I tried http://127.0.0.1:5000/ in browser and it is not showing anything
I am new this and tried a simple thing
/r/flask
https://redd.it/1lsjhhl
I had no idea changing a Django Project Name was that easy; I recorded the process in case others are afraid of trying...
Up until very recently I was super nervous about changing a Django project's name. I always thought it would mess everything up, especially with all the imports and settings involved.
But once I actually tried it, I realized it is a very simple process.. It only takes a few minutes (if not seconds). I put together a short tutorial/demonstration in case anyone else is feeling the same anxiety about it.
In the video, I walk through renaming a freshly cloned Django starter project.
Here is the link:
https://youtu.be/Ak4XA5QK3\_w
I would love to hear your thought &&/|| suggestions.
/r/django
https://redd.it/1lty35t
Resolving inconsistent speeds on Railway
Hi everyone!
I have a Django+HTMX app - easypumf.com \- hosted on Railway (Hobby tier), and HTTP request load times are quite inconsistent. "Waiting for server response" times are often very slow (1-15 seconds), but can then be normal (150-250ms) for no apparent reason. There is no real pattern to speeds (so it's not like it is getting faster after a few refreshes). I also do not have the "serverless" option enabled.
My app has no such problem in my local environment. This issue affects every request, including simple partial HTML page loads with no DB connections or large static files. I tried: 1) using cache_control and Cloudflare to cache static pages; 2) adding a Procfile to increase the numbers of workers; 3) refactoring to minimise DB connections. Nothing worked so far.
I tried reaching out to Railway's support site, but I don't have much hope there.
Can anyone help me figure this out? I'd greatly appreciate it :)
/r/django
https://redd.it/1ltqukh
D Remembering Felix Hill and the pressure of doing AI research
Before he left our world by a few days around Oct 2024, I showed Felix Hill an essay I had written about my time in graduate school doing NLP circa 2017-2019.
He encouraged me to share it publicly saying, “It looks good and makes a lot of sense..if you post it it will surely help you and others”
I didn’t have the courage to post about such a personal experience. But as Dostoyevsky would say “much unhappiness has come into the world because of bewilderment and things left unsaid.”
The article garnered the attention of Jeff Dean and he echoed similar feedback.
Here is the article:
tahaymerghani/the-dark-side-of-academia-mental-health-mentorship-and-the-unspoken-struggles-of-an-nlp-c25adbd9a2e6" rel="nofollow">https://medium.com/@tahaymerghani/the-dark-side-of-academia-mental-health-mentorship-and-the-unspoken-struggles-of-an-nlp-c25adbd9a2e6
If it resonates, i’m happy to chat. You’ll find a way to reach me.
/r/MachineLearning
https://redd.it/1ltejq6
Part-time/3-4 months freelance backend
Hey guys i’m looking for a part-time or a freelance 3/4 months job. I’m a backend engineer with experience in django and node.js for frameworks, Docker and AWS for deployment and infrastructure , Databases: Redis, PG , Mysql, mssql ,in addition to experience with fine-tuning transformer models. If anyone has anything of sorts can you hit me up and i’ll send you my cv. Thanks!
/r/django
https://redd.it/1lt7drg
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/1ltfxpq
We built an AI-agent with a state machine instead of a giant prompt
Hola Pythonistas,
Last year we tried to bring an LLM “agent” into a real enterprise workflow. It looked easy in the demo videos. In production it was… chaos.
* Tiny wording tweaks = totally different behaviour
* Impossible to unit-test; every run was a new adventure
* One mega-prompt meant one engineer could break the whole thing • SOC-2 reviewers hated the “no traceability” story
We wanted the predictability of a backend service and the flexibility of an LLM. So we built NOMOS: a step-based state-machine engine that wraps any LLM (OpenAI, Claude, local). Each state is explicit, testable, and independently ownable—think Git-friendly diff-able YAML.
Open-source core (MIT), today.
* GitHub: [https://github.com/dowhiledev/nomos](https://github.com/dowhiledev/nomos)
* Documentation: [https://nomos.dowhile.dev](https://nomos.dowhile.dev)
Looking ahead: we’re also prototyping Kosmos, a “Vercel for AI agents” that can deploy NOMOS or other frameworks behind a single control plane. If that sounds useful, Join the waitlist for free paid membership for limited amount of people.
[https://nomos.dowhile.dev/kosmos](https://nomos.dowhile.dev/kosmos)
Give us some support by contributing or simply by starring our project and Get featured in the website instantly.
Would love war stories from anyone who’s wrestled with flaky prompt agents. What hurt the most?
/r/Python
https://redd.it/1lsw6ka
Built a Python-based floating HUD for developers.
Hey everyone,
I recently finished a project called DevHUD, a floating heads-up display for desktop built with Python (using PyQt5). It’s designed to stay on top of your workspace and provide quick access to useful tools without disrupting your workflow.
# What My Project Does
DevHUD displays system stats, clipboard history, GitHub activity, a focus timer, theme settings, and music player all in a compact, always-on-top interface. It’s meant to help developers reduce context switching and stay focused without leaving their active window.
# Target Audience
DevHUD is intended for developers and power users who want lightweight productivity tools that stay out of the way. While it’s still early in development, it’s stable enough for personal use and I’m actively seeking feedback to improve it.
# Comparison
Unlike full-fledged productivity dashboards or browser-based extensions, DevHUD is a desktop-native, Python-based app built with PyQt5. It focuses only on core features without unnecessary bloat, and runs quietly in the corner, kind of like a HUD in a game, but for your dev setup. Its simplicity and modular design are what set it apart.
Links:
GitHub: https://github.com/ItsAkshatSh/DevHUD
Website: https://devhud.vercel.app
YouTube Series: CodingtillIgotoanisland">CodingtillIgotoanisland" rel="nofollow">https://www.youtube.com/@CodingtillIgotoanisland
Would love feedback on the tool, UI, or code structure, happy to discuss or answer questions.
Thanks!
/r/Python
https://redd.it/1lt1tav
We built an AI-agent with a state machine instead of a giant prompt
/r/IPython
https://redd.it/1lswmbe
Help with my understanding of Flask teardown logic
Hello, I need some clarification of my understanding of this issue. Do I really the following teardown logic at all or not? Long story short, Ive been struggling with password resets. And somewhere between the mess of Git commits, I keep adding stuff, just in case. Its usually some other issue I solved, and I solve eventually. The question is I want to really know if the teardown logic is necessay.
I read somewhere, that Flask does this automaatically anyway (it has something to do with g, request context), and you dont need i even with app.app_context().push(). But I keep adding this, only to solve it anyway using something else. The reason why I keep adding this back, is becoz CSRF related errors keep popping between fixes. I want to remove it once and for all
@app.teardownrequest
def teardownrequest(responseorexc):
db.session.remove()
@app.teardownappcontext
def teardownappcontext(responseorexc):
db.session.remove()
/r/flask
https://redd.it/1lsv1dp
How many models should an app have?
Hello, I'm developing a simple onlins bookstore project. In my shop app, I have about 20 models. Is this ok, or bad practice?
/r/djangolearning
https://redd.it/1lscnh2
Web push notifications from Django. Here's the tutorial.
https://youtu.be/grSfBbYuJ0I?feature=shared
/r/django
https://redd.it/1lsrgvl
For running Python scripts on schedule or as APIs, what do you use?
Just curious, if you’ve written a Python script (say for scraping, data cleaning, sending reports, automating alerts, etc.), how do you usually go about:
1. Running it on a schedule (daily, hourly, etc)?
2. Exposing it as an API (to trigger remotely or integrate with another tool/app)?
Do you:
Use GitHub Actions or cron?
Set up Flask/FastAPI + deploy somewhere like Render?
Use Replit, AWS Lambda, or something else?
Also: would you ever consider paying (like $5–10/month) for a tool that lets you just upload your script and get:
A private API endpoint
Auth + input support
Optional scheduling (like “run every morning at 7 AM”) all without needing to write YAML or do DevOps stuff?
I’m trying to understand what people prefer. Would love your thoughts! 🙏
/r/Python
https://redd.it/1lsgsqn
An analytic theory of creativity in convolutional diffusion models.
https://arxiv.org/abs/2412.20292
/r/MachineLearning
https://redd.it/1lsipgp
Deepface authentication - library and demo site
I recently published under the MIT License a Django app for face recognition authentication using DeepFace and pgvector. It's intended for audiences where the same group of people authenticate frequently without remembering their passwords, or want minimal keyboard usage. It uses the camera built in to your laptop or screen - in the same way you might use MS Teams, Google Meet, or WhatsApp.
It works fine with a good CPU, but will fly with a GPU.
I would probably use it with the default settings, but there are options you can experiment with in different environments. Because of the use of pgvector, which is currently not indexed, but can be very simply, it should be possible to support many thousands of user.
Github stars and comments appreciated.
https://github.com/topiaruss/django-deepface
/r/django
https://redd.it/1lu7hou
Using Celery to manage background tasks with Flask
It has been a long time writing blogs. We intend to share knowledge in a esay to understand format. Kindly visit the link below to understand the same.
https://flask-india.hashnode.dev/using-background-tasks-with-celery-in-flask#heading-lets-get-started
/r/flask
https://redd.it/1ltbjda
Both of these sites are created using flask backend
yourtattoo.art
telegramindex.org
like to hear your feedbacks
/r/flask
https://redd.it/1ltk8kb
How are you using just (Justfile) local workflows for Python projects?
Hynek Schlawack just put out another great video on uv (https://youtu.be/TiBIjouDGuI?si=lBfoBG8rgUFcS3Sx), this time also discussing how he uses the just tool to store commands in a cross-platform portable way to do everyday tasks like installing/refreshing virtual environments, running tests/code checks, and development tasks like sending requests.
Is this getting common in Python land? I know it is among Rustaceans (where I first saw it a few months ago), anyone have good examples they wrote/saw, or experiences? Very curious to hear more: Hynek’s style of usage is quite different to how I have been using them. Links to example Justfiles welcome!
I am mainly using them for pre-commit/pre-push checks and to make CI setup ‘self-documenting’ (i.e. clear what is run, from where)
/r/Python
https://redd.it/1ltr3n1
There is such a thing as "too much TQDM"
TIL that 20% of the runtime of my program was being dedicated to making cute little loading bars with fancy colors and emojis.
Turns out loops in Python are not that efficient, and I was putting loops where none were needed just to get nice loading bars.
/r/Python
https://redd.it/1lthva4
Why do you use Flask?
What do you do that needs Flask? Tell me Abt it
/r/flask
https://redd.it/1ltdloi
ImGui Bundle: (web) apps in pure Python
I am the author of ["Dear ImGui Bundle"](https://pthom.github.io/imgui_bundle/index.html), a fully open-source GUI framework for Python,
using the “Immediate Gui” paradigm.
I recently made it available on the Web via Pyodide, and I thought it was worth sharing to the broader Python community.
Read the following article to learn more about it, and how it compares to other Python web frameworks like Streamlit or Gradio.
> [**(Web) Apps in pure Python using ImGui Bundle**](https://code-ballads.net/dear-imgui-bundle-build-real-time-python-web-applications-with-zero-fuss/)
## What "Dear ImGui Bundle" Does
* ImGui Bundle brings to Python the Immediate Mode GUI paradigm, which enables rapid prototyping of interactive applications
with a code that is highly readable and maintainable.
* Provide python bindings for the C++ “immediate-mode” GUI library **Dear ImGui**, as well as scientific utilities and many widgets.
* Run natively on a PC *or* in the browser via Pyodide, with the same code
## Target Audience
* Data-viz prototypers
* Scientific tools
* real-time tools needing 60 FPS interactivity
* Anyone who wants to deploy tools to the web without touching JS/CSS
## Comparison
| Feature | Dear ImGui Bundle | Streamlit / Gradio |
|---------|------------------|--------------------|
| Rendering | GPU immediate-mode | HTML/CSS → DOM |
| Event model | Synchronous frame loop | Async client-server |
| Browser deploy | Pyodide (no server) | Needs backend
/r/Python
https://redd.it/1ltalg4
My first web app w/Flask
Repo:
https://github.com/SalvoLombardo/mascagnidemo
I just finished my first full web app built with Flask after about five months of learning on my own. It’s a simple app for a small music association that runs yearly subscription campaigns.
I’ve studied a lot in the last 5 months but I know this is just the start. There are some features that are missing but I spent around 2-3 weeks and I’m exhausted and I need to go further in my path.
——
https://mascagni-demo-e0f00e6ab048.herokuapp.com
user:admindemo
pass:demo
If you want to try some functionality, right now doesn’t have too much data in the db, just the necessary
———-
Some quick highlights:
• User auth (register/login/logout)
• Admin panel with full CRUD
• Modular design with Flask Blueprints
• Custom forms with Flask-WTF
• Basic security: CSRF protection and bcrypt password hashing
One interesting thing is the way the app handles subscribers — no unique phone/email constraints — because the association wanted to keep it close to their paper-based workflow in a small town.
Admins create campaigns and assign ticket batches, and operators sell tickets only after that. Operators can edit only their own data, while admins have full control.
I’d love any feedback or suggestions — I’m still learning and would appreciate input from anyone experienced.
Thanks!
/r/flask
https://redd.it/1lsfwtb
ANN django-smart-ratelimit: A simple, flexible rate-limiting library for Django
Hey everyone! I just released django-smart-ratelimit v0.3.0—a lightweight, configurable rate-limiting solution for Django projects. I’d love to get early feedback from the community.
# 🔍 What it does
Per-view, per-IP and global limits out of the box
Supports function-based and class-based views
Pluggable storage backends (cache, Redis, etc.)
Simple decorator and mixin API
Multiple Algorithms (sliding\_window, fixed\_window, and more soon)
# 🚀 Quickstart
pip install django-smart-ratelimit
# views.py
from django_smart_ratelimit.decorator import ratelimit
@rate_limit(key='ip', rate='10/m', block=True)
def my_view(request):
return HttpResponse("Hello, rate-limited world!")
PYPI Link [https://pypi.org/project/django-smart-ratelimit/](https://pypi.org/project/django-smart-ratelimit/)
Full docs and examples 👉 [https://github.com/YasserShkeir/django-smart-ratelimit](https://github.com/YasserShkeir/django-smart-ratelimit)
# 🛣️ Roadmap
Check out the full feature roadmap here:
[https://github.com/YasserShkeir/django-smart-ratelimit/blob/main/FEATURES\_ROADMAP.md](https://github.com/YasserShkeir/django-smart-ratelimit/blob/main/FEATURES_ROADMAP.md)
# ❓ Feedback & Contributions
Tried it in your project? Let me know how it went!
Found a bug or want an enhancement? Open an issue or PR on GitHub.
General questions? Ask below and I’ll be happy to help.
Thanks for your time—looking forward to your thoughts!
— Yasser (creator)
/r/django
https://redd.it/1lsvvdg
Solving Wordle using uv's dependency resolver
What this project does
Just a small weekend project I hacked together. This is a Wordle solver that generates a few thousand Python packages that encode a Wordle as a constraint satisfaction problem and then uses uv's dependency resolver to generate a lockfile, thus coming up with a potential solution.
The user tries it, gets a response from the Wordle website, the solver incorporates it into the package constraints and returns another potential solution and so on until the Wordle is solved or it discovers it doesn't know the word.
Blog post on how it works here
Target audience
This isn't really for production Wordle-solving use, although it did manage to solve today's Wordle, so perhaps it can become your daily driver.
Comparison
There are lots of other Wordle solvers, but to my knowledge, this is the first Wordle solver on the market that uses a package manager's dependency resolver.
/r/Python
https://redd.it/1lsuqis
We built an AI-agent with a state machine instead of a giant prompt
/r/IPython
https://redd.it/1lsw3k3
Python as essentially a cross-platform shell script?
I’m making an SSH server using OpenSSH, and a custom client interface. I’m using Python as the means of bringing it all together: handling generation of configs, authentication keys, and building the client interface. Basically a setup script to cover certain limitations and prevent a bunch of extra manual setup.
Those (to me) seem like tasks that shell scripts are commonly used for, but since those scripts can vary from system to system, I chose to use Python as a cross-platform solution. That sorta got me thinking, have any of you ever used Python this way? If so, what did you use it for?
/r/Python
https://redd.it/1lss8mg
What's your take on Celery vs django-qstash for background tasks
Hello guys, I'm currently working on a personal project and would like to know your thoughts and advice on handling background tasks in django.
My use cases includes:
1. Sending transactional emails in the background
2. Some few periodic tasks
Celery is super powerful and flexible, but it requires running a persistent worker which can get tricky or expensive on some platforms like Render. On the other hand, QStash lets you queue tasks and have them POST to your app without a worker — great for simpler or cost-sensitive deployments.
Have you tried both? What are the treadoffs of adopting django-Qstash.
/r/django
https://redd.it/1lsneon
Sunday Daily Thread: What's everyone working on this week?
# Weekly Thread: What's Everyone Working On This Week? 🛠️
Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
## How it Works:
1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.
## Guidelines:
Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
## Example Shares:
1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
/r/Python
https://redd.it/1lsnrbz
Robyn now supports Server Sent Events
For the unaware, Robyn is a super fast async Python web framework.
Server Sent Events were one of the most requested features and Robyn finally supports it :D
Let me know what you think and if you'd like to request any more features.
Release Notes - https://github.com/sparckles/Robyn/releases/tag/v0.71.0
/r/Python
https://redd.it/1ls89sy