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
🚀 Introducing TkRouter — Declarative Routing for Tkinter

Hey folks!

I just released TkRouter, a lightweight library that brings declarative routing to your multi-page Tkinter apps — with support for:

Features:
- /users/<id> style dynamic routing
- Query string parsing: /logs?level=error
- Animated transitions (slide, fade) between pages
- Route guards and redirect fallback logic
- Back/forward history stack
- Built-in navigation widgets: RouteLinkButton, RouteLinkLabel

Here’s a minimal example:

from tkinter import Tk
from tkrouter import create_router, get_router, RouterOutlet
from tkrouter.views import RoutedView
from tkrouter.widgets import RouteLinkButton

class Home(RoutedView):
def __init__(self, master):
super().__init__(master)
RouteLinkButton(self, "/about", text="Go to About").pack()

class About(RoutedView):
def __init__(self, master):
super().__init__(master)
RouteLinkButton(self, "/", text="Back to Home").pack()

ROUTES = {
"/": Home,
"/about": About,
}

root = Tk()
outlet = RouterOutlet(root)
outlet.pack(fill="both", expand=True)
create_router(ROUTES, outlet).navigate("/")
root.mainloop()


📦 Install via pip
pip install tkrouter


📘 Docs
https://tkrouter.readthedocs.io

💻 GitHub
https://github.com/israel-dryer/tkrouter

🏁 Includes built-in demo commands like:
tkrouter-demo-admin     # sidebar layout with query params
tkrouter-demo-unified # /dashboard/stats with transitions
tkrouter-demo-guarded # simulate login and access guard


Would love feedback from fellow devs. Happy to answer questions or take

/r/Python
https://redd.it/1kew6fz
Apk for sports forecasts

I have a super good page with football predictions, can anyone create an APK and put those predictions there? If it is possible?

/r/Python
https://redd.it/1kf29oy
DVD Bouncing Animation

* **What My Project Does:** Creates a simple animation which (somewhat) replicates the old DVD logo bouncing animation displayed when a DVD is not inserted
* **Target Audience:** Anyone, just for fun
* **Comparison**: It occurs in the command window instead of a video

(Ensure windows-curse is installed by entering "pip install windows-curses" into command prompt.


GitHub: [https://github.com/daaleoo/DVD-Bouncing](https://github.com/daaleoo/DVD-Bouncing)

/r/Python
https://redd.it/1keblmk
Query about celery

Is someone who can send me a best free video link or documents to get knowledge about celery and channels in Django ?

/r/django
https://redd.it/1kf35j2
Data Structure Algorithm in python

Hey everyone! I'm currently learning Data Structures and Algorithms (DSA) using Python. I'd love to connect with others on the same journey maybe we can study, share resources, or solve problems together!

/r/Python
https://redd.it/1kf66ct
Read pdf as html

Hi,

Im looking for a way in python using opensource/paid, to read a pdf as html that contains bold italic, font size new lines, tab spaces etc parameters so that i can render it in UI directly and creating a new pdf based on any update in UI, please suggest me is there any options that can do this job with accuracy

/r/Python
https://redd.it/1kf640j
ChatForge: A free, open-source AI chat client with 300+ models (GPT-4, Claude 3, etc.)—no subscriptions, pay-per-token!

I’ve been working on ChatForge—a no-BS, open-source chat client that lets you access 318+ AI models (GPT-4.1 Mini, Claude 3.7, Qwen, Gemini, etc.) from one dashboard. No upfront costs, no monthly fees—just pay for tokens you actually use.

Why bother?

Free-tier models: Test drive without even adding a payment method.
Persistent chats: Name/organize convos like files (RIP losing your 2am AI rants).
Customizable: Set default models, API keys, etc.
Simple UI: Not a design award winner, but it’s clean and functional (I’m a dev, not a designer—sue me).

It’s 100% free and community-driven. I’d love feedback (or contributions if you’re into Python/Django).

Try it or roast it:
🔗 GitHub

P.S. If you’ve tried similar tools (like OpenRouter’s web UI), how’s this compare? Honest takes welcome.

/r/django
https://redd.it/1kf89nu
Read pdf as html

Hi,

Im looking for a way in python using opensource/paid, to read a pdf as html that contains bold italic, font size new lines, tab spaces etc parameters so that i can render it in UI directly and creating a new pdf based on any update in UI, please suggest me is there any options that can do this job with accuracy

/r/Python
https://redd.it/1kf641m
How would you handle achievements and achievement progress n a Django app?

I’m working on a Django web app where I want to introduce badges/achievements for users — things like:

* Play 10 random quizzes in a day
* Finish 100 quizzes in total
* Play 7 days in a row

Here’s the basic model setup I’m considering:
```
class Achievement(models.Model):
code = models.CharField(max_length=100, unique=True) # e.g., 'play_10_quizzes'
name = models.CharField(max_length=200)
description = models.TextField()
icon = models.ImageField(upload_to='achievement_icons/', null=True, blank=True)

class UserAchievement(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
achievement = models.ForeignKey(Achievement, on_delete=models.CASCADE)
unlocked_at = models.DateTimeField(auto_now_add=True)

class Meta:
unique_together = ('user', 'achievement')
```

How best to save and calculate/track user progress toward an achievement?

I’ve been reading that using Django signals might not be the best approach here, and I’m wondering what patterns or architecture others have used.

**Specifically:**

* Do you calculate achievement progress dynamically (on the fly) when the frontend requests it?
* Or do you store progress in the database and increment it every time an action happens (e.g., quiz completed), so reads are faster?
* How do you handle edge cases, like historical data changes or deletions?
* Any tips on scaling this

/r/django
https://redd.it/1kf9a2b
Any repo on learning pywebview bundling for Mac

Any guide I can follow, I need to add spacy model along with bundle, it increases the size of the app, also the app isn’t able to connect to the backend once I build using Pyinstaller but works well while running locally.

/r/Python
https://redd.it/1kf4rlf
Why should one write tests?

First of all I will not question whether it is necessary to write tests or not, I am convinced that it is necessary, but as the devil's advocate, I'd like to know the real good reasons for doing this. Why devil's advocate? I have my app, that is going well (around 50k users monthly). In terms of complexity it's definetely should be test covered. But it's not. At all. Yeah, certainly there were bugs that i caught only in production, but i can't understand one thing - if i write tests for thousands cases, but just don't think of 1001 - in any case something should appear in prod. Not to mention that this is a very time consuming process.


P.S. I really belive I'll cover my app, I'm just looking for a motivation to do that in the near future

/r/django
https://redd.it/1kfbsc0
strif: A tiny, useful Python lib of string, file, and object utilities

I thought I'd share **strif**, a tiny library of mine. It's actually old and I've used it quite a bit in my own code, but I've recently updated/expanded it for Python 3.10+.

I know utilities like this can evoke lots of opinions :) so appreciate hearing if you'd find any of these useful and ways to make it better (or if any of these seem to have better alternatives).

What it does: It is nothing more than a tiny (\~1000 loc) library of \~30 string, file, and object utilities.

In particular, I find I routinely want atomic output files (possibly with backups), atomic variables, and a few other things like base36 and timestamped random identifiers. You can just re-type these snippets each time, but I've found this lib has saved me a lot of copy/paste over time.

Target audience: Programmers using file operations, identifiers, or simple string manipulations.

Comparison to other tools: These are all fairly small tools, so the normal alternative is to just use Python standard libraries directly. Whether to do this is subjective but I find it handy to `uv add strif` and know it saves typing.

boltons is a much larger library of general utilities. I'm sure a lot of it

/r/Python
https://redd.it/1kfksn1
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/1kfqwcv
Are there any boilerplates or templates you are using currently? If so, what is your project?

Want to learn to review code and get a sense for proper structure and gain in depth knowledge about overall development. What modules are a must for your development? I also enjoy reading about another developer’s workflow and productivity.

/r/flask
https://redd.it/1kfvibz
[Hiring] Full stack dev with REACT Js & Django Experience

Need an experienced dev with plenty of experience building scalable web and mobile apps. The role is open to anyone in the world.

Pay: $75 AUD / hr. 20 hours need per week now, but more will be needed later on.

**Some crucial skills:**

* Amazing design skills. You need to be a very creative designer and know how to use CSS (and tailwind CSS)
* Worked with projects that use heaps of CRUD operations
* Understanding on how to build scalable APIs. Some past web apps we’ve built have brought in 1M+ users per month, so the backend needs to be built to scale!
* File storing, S3 and data handling
* Experience with both Django and REACT js
* Experience with REACT Native as well
* (optional) experience with building software that uses WAV & MP3 files
* Thorough knowledge around algorithm development
* Experience with building unique programs in the past with custom functionality.

**Hours & Pay:**

Email me if interested - [admin@outreachaddict.com](mailto:admin@outreachaddict.com). Please include links to stuff you’ve worked on in the past.  

/r/Python
https://redd.it/1kfup52
Using Django+Sqlite in production

I've been researching the use of Sqlite in production and came across this thread which has some resources, mainly about the benefits and also how to performance tune Sqlite.

My intent right now is to keep my app on Sqlite. The application is a B2B app with limited number of users, and it is not write heavy (a few hundred writes per day). It also simplifies my tech stack.

I'd like to check if someone has resources specific on how to deploy and run a Django+Sqlite app.

Over in the Ruby on Rails world, I saw a movement to help developers achieve this, and was wondering if there is something equivalent in the Django.

/r/django
https://redd.it/1kfuuys
Cogitator - A Python Toolkit for Chain-of-Thought Prompting

GitHub Link: [https://github.com/habedi/cogitator](https://github.com/habedi/cogitator)

**What my project does**

Cogitator is a Python library/toolkit that makes it easier to experiment with and use various chain-of-thought (CoT) prompting methods for large language models (LLMs). CoT prompting is a family of techniques that helps LLMs improve their reasoning and performance on complex tasks (like question-answering, math, and problem-solving) by guiding them to generate intermediate steps before giving a final answer.

Cogitator currently provides:

* Support for OpenAI and Ollama as LLM backends.
* Implementations for popular CoT strategies such as Self-Consistency, Tree of Thoughts (ToT), Graph of Thoughts (GoT), Automatic CoT (Auto-CoT), Least-to-Most Prompting, and Clustered Distance-Weighted CoT.
* A unified sync/async API for interacting with these strategies.
* Support for structured model outputs using Pydantic.
* A basic benchmarking framework.

The project is in beta stage. The README in the GitHub repository has more details, installation instructions, and examples.

**Target audience**

* AI/ML researchers looking to experiment with or benchmark different CoT techniques.
* Python developers who want to integrate more advanced reasoning capabilities into their LLM-powered applications.

In general, CoT could be useful if you're working on tasks that need multi-step reasoning or want to improve the reliability of LLM outputs for more complicated queries.

**Why I made this**

I started developing Cogitator because I found that

/r/Python
https://redd.it/1kg2b2p
PyCon US 2025 is next week!

# PyCon US 2025 Quickly Approaches!

You still have time to register for our annual in-person event. Check out the official schedule of talks and events!

# Links

[Register Now](https://us.pycon.org/2025/registration/register)
PyCon Blog Announcement
[PyLadies Auction Donations](https://pycon.blogspot.com/2025/03/support-pyladies-donate-to-pyladies.html)
Keynote Speaker and Schedule Announcements

~~You have 30 days until the early bird pricing is gone!~~

The early bird pricing is gone, but you still have a chance to get your tickets.

# Details

May 14 - May 22, 2025 - Pittsburgh, Pennsylvania Conference breakdown:

Tutorials: May 14 - 15, 2025
Main Conference and Online: May 16 - 18, 2025
Job Fair: May 18, 2025
Sprints: May 19 - May 22, 2025 (What to expect at sprints)


edited, dates are hard

/r/Python
https://redd.it/1kg5xvh
Looking for help regarding a flask project (I want to input question (with both text and equations) , save it in MySQL and print in both word doc and pdf)

I am working on a basic question paper generator where users can enter questions for each subject, and the the questions are saved in MySQL. The admin can generate question papers in form of both pdf and word. I am unable to find a way to let users to add questions that has equations or formulas. I tried using tinymce and mathjack but it doesn't seem to support all formats (like the bigger fractions). I also tried rendering latex to text or image and is too complicated for me to understand how to make it work properly. I do not want to paste the equation/formula as an image in the word file, I need to to be in proper human readable format. I want the outputs both in word and pdf formats. Please help.

Eg. equation

/r/flask
https://redd.it/1kg3nx7
I built my own asyncio to understand how async I/O works under the hood

Hey everyone!

I've always been a bit frustrated by my lack of understanding of how blocking I/O actions are actually processed under the hood when using async in Python.

So I decided to try to build my own version of asyncio to see if I could come up with something that actually works. Trying to solve the problem myself often helps me a lot when I'm trying to grok how something works.

I had a lot of fun doing it and felt it might benefit others, so I ended up writing a blog post.

Anyway, here it is. Hope it can help someone else!

👉 https://dev.indooroutdoor.io/asyncio-demystified-rebuilding-it-from-scratch-one-yield-at-a-time

EDIT: Fixed the link

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