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
PEP 791 – imath — module for integer-specific mathematics functions

# PEP 791 – imath — module for integer-specific mathematics functions

https://peps.python.org/pep-0791/

# Abstract

This PEP proposes a new module for number-theoretical, combinatorial and other functions defined for integer arguments, like `math.gcd()` or `math.isqrt()`.

# Motivation

The `math` documentation says: “This module provides access to the mathematical functions defined by the C standard.” But, over time the module was populated with functions that aren’t related to the C standard or floating-point arithmetics. Now it’s much harder to describe module scope, content and interfaces (returned values or accepted arguments).

For example, the `math` module documentation says: “Except when explicitly noted otherwise, all return values are floats.” This is no longer true: None of the functions listed in the Number-theoretic functions subsection of the documentation return a float, but the documentation doesn’t say so. In the documentation for the proposed imath module the sentence “All return values are integers.” would be accurate. In a similar way we can simplify the description of the accepted arguments for functions in both the `math` and the new module.

Apparently, the `math` module can’t serve as a catch-all place for mathematical functions since we also have the `cmath` and `statistics` modules. Let’s do the same for integer-related functions. It provides shared context, which

/r/Python
https://redd.it/1kqrqgb
Django CMS vs Django Wagtail?

We're building a headless API using Django. Most of our application doesn't require a CMS — it's primarily about managing structured data via the Django admin. However, for marketing and sales pages, we need to give non-technical users (like marketers or content creators) the ability to:

Create custom pages for products
Move and reorder content blocks (flexible layouts)
Duplicate pages or sections
Reuse existing structured data like testimonials, teacher bios, product metadata, etc.

The idea is:

1. We create a Product in the Django admin, filling out all necessary metadata (e.g. delivery info, pricing, etc.).
2. Then, we want to create sales/landing pages for that product, possibly multiple variations, that can pull in and reuse the structured metadata.

# The Question:

Given the above, which CMS is a better fit: Django CMS or Wagtail?

/r/django
https://redd.it/1kqubqw
PostGres connections running out with Azure

I am using AzureStorage for the backend of my django app. I thus have the following settings:

DATABASES = {
"default": {
"NAME": "compliancebotdbdjango",
"ENGINE": "django.db.backends.postgresql",
"TOKEN": DefaultAzureCredential().get
token("https://database.windows.net/.default"),
"USER": os.environ"POSTGRES_USER",
"PASSWORD": os.environ"POSTGRES_PASSWORD",
"HOST": os.environ"POSTGRES_SERVER",
"PORT": "5432",
"CONNMAXAGE": 10,
"CONNHEALTHCHECKS": True,


/r/djangolearning
https://redd.it/1kqfz8u
Django Multi Language

Hi Everyone,

need suggestion for https://rohanyeole.com for translating entire site in multi languages.

I'm looking into URL

likedomain-url/en/

domain-url/vi/blog-slug

and so on.

is there way to do it without po files.

/r/djangolearning
https://redd.it/1kojekc
Frontend

I need a frontend for my drf project, want to try react, but I'll have to learn JS, is there any other framework which is easier to learn or I can nitpick on the JS fundamental to work with react? I have no intention of being a full stack dev.


/r/django
https://redd.it/1kra4bx
What Feature Do You Wish Python Had?

What feature do you wish Python had that it doesn’t support today?

Here’s mine:

I’d love for Enums to support payloads natively.

For example:

from enum import Enum
from datetime import datetime, timedelta

class TimeInForce(Enum):
GTC = "GTC"
DAY = "DAY"
IOC = "IOC"
GTD(d: datetime) = d

d = datetime.now() + timedelta(minutes=10)
tif = TimeInForce.GTD(d)


So then the TimeInForce.GTD variant would hold the datetime.

This would make pattern matching with variant data feel more natural like in Rust or Swift.
Right now you can emulate this with class variables or overloads, but it’s clunky.

What’s a feature you want?

/r/Python
https://redd.it/1kr0dnr
New to this: Works in terminal but not in Juipyter?

/r/IPython
https://redd.it/1kr52ig
Learning Machine Learning and Data Science? Let’s Learn Together!

I’m currently diving into the exciting world of machine learning and data science. If you’re someone who’s also learning or interested in starting, let’s team up!

We can:

Share resources and tips

Work on projects together

Help each other with challenges

Doesn’t matter if you’re a complete beginner or already have some experience. Let’s make this journey more fun and collaborative. Drop a comment or DM me if you’re in!

/r/Python
https://redd.it/1kr8cvg
Updated from 3.x to 5.2, now I'm getting "Obj matching query does not exist"

I'm using Django in a non-Django project purely to make my unit tests easier. I've defined all my models like this:

class Bar(models.Model):
internaltype = models.TextField(...)
...

class Meta:
managed = False
db
table = 'myschema\".\"bar'

class Foo(models.Model):
...
bar = models.ForeignKey('Bar', models.DONOTHING, dbcolumn='bar', blank=True, null=True)

class Meta:
managed = False
dbtable = 'myschema\".\"foo'

This looks funky, but it was working perfectly fine on Django 3.2. It allowed me to write tests like this:


def test
foo(self):


/r/django
https://redd.it/1krjrck
Speeding up testing with cursor

I have been building in django since before cursor / co-pilot days. The speed I can now develop and deploy is insane compared to the "old" days. The only area that still feels slow and clunky is writing test scripts. Even when I write really long contexts and attach endless files, the output is pretty crap. What am I missing? All tips and tricks much appreciated

/r/django
https://redd.it/1krajqu
I'm Building With Flask. It's Pretty Good.

I just wanted to share my experience building with Flask. I only remember using it from tutorials at my High School, so I only knew the basics of what it did.

Now a few years into college with a plan to freelance. I wanted to make a simple app that would help me get potential clients because I thought it would be fun to develop and I was too lazy to go through the process of finding clients. I usually use django in these projects, but I figured it would be much simpler developing with Flask and I gave it a try.


It turns out it was much easier than I thought. While things aren't as straightforward with django, implementing things felt much more simple. I'm almost done with my app, but I'm likely going to add more features to it as I develop it.

TLDR ; Made project with Flask, Flask cool, Flask simple




/r/flask
https://redd.it/1kr84wc
Dynamic Forms builder for admins

Hi! It's my first time developing a personal project using Flask and MySQL to manage medical records for patients, and I'm using HTML, CSS with Bootstrap for the frontend. Here's what I thought:

* An administrator creates dynamic forms with custom fields and makes them available to the doctors. Then, the doctors can use these forms for their patients in the future. For example: Create a new form → question 1 title → type of answer (number, text, date, etc.) → add as many questions as needed → save the form → it becomes available for doctors to use.
* Doctors will be able to select which form to use for each patient.
* When a patient returns, doctors should be able to **edit** the records associated with that form.

I already have the database tables (I can share them if that helps you understand the structure).
I’ve seen some React projects that look interesting, but I’ve never used React before. That’s why I’d prefer to stick with Flask if it’s the best option for now.

What do you recommend? Is there a plugin for Flask or another technology I should consider?

Thank you!

/r/flask
https://redd.it/1kr3kze
Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1krk3ef
Why even use Flask when FastAPI exists?

Why still use Flask when FastAPI can do everything Flask does and more with less effort?

FastAPI gives you modern Python features by default: async support without hacks, automatic request validation using type hints, and OpenAPI documentation generated instantly. You don’t need to reach for third-party libraries to get input validation, serialization, or proper HTTP error handling they're first-class citizens. You get data parsing, input constraints, and clear API contracts with almost no boilerplate.

Flask, on the other hand, makes you build all of that yourself. It’s flexible, yes, but that flexibility often means reinventing wheels that FastAPI gives you for free. Want JSON schema validation in Flask? You choose and integrate a library. Want async? Be careful Flask's async support is still evolving and lacks the maturity of FastAPI’s. Want type safety and editor support? Good luck.

So for new projects, what’s the argument in favor of Flask? Legacy familiarity? A massive plugin ecosystem that you now have to glue together yourself? Isn’t it time we stop treating Flask’s simplicity as a strength when it just leads to more work?

If you’re still choosing Flask in 2025, what’s the compelling reason? What does it actually do better?

/r/flask
https://redd.it/1kr317a
Modern Python Boilerplate - good package basic structure

*TL;DR: Python Boilerplate repo for fast package building with all best practices* 

Hello,

I wanted to share a small repository I made named “Modern Python Boilerplate”. I created it because I saw in multiple projects including in professional environnement, the lack of good structure and practice, leading to ugly code or even non-functional, environnement mess…

* **What My Project Does**

The goal is to provide a python repository setup that provides all the best good-practices tool available and pre-configure them. It makes it easy to build and publish python package !

**The link is here** [**https://github.com/lambda-science/modern-python-boilerplate**](https://github.com/lambda-science/modern-python-boilerplate)

* **Comparison** (A brief comparison explaining how it differs from existing alternatives.)

It include modern python management (structure, packaging, version and deps w/ UV), modern CI (listing, formatting, type checking, testing, coverage, pre-commit hooks w/ Ruff/Ty), documentation (automatic API Reference building and publishing on Github/Gitlab w/ Mkdocs) and running (basic Dockerfile, Makefile, DevContainer tested on Pycharm, module running as a terminal command…)

* **Target Audience** (e.g., Is it meant for production, just a toy project, etc.)

Anyone building anything in Python that is starting a new project or try to modernize an existing one


Don’t hesitate to share feedback or comments on this, what could be improved.

I heard for example that some people

/r/Python
https://redd.it/1krsxut
Django tip Customize Your Django Admin with django-unfold

/r/django
https://redd.it/1kruwht
Meet OctaProbe - Yet another security assessment tool

Hey guys, I made this tool for my final year computer science project!

Built entirely using Python, and Streamlit

What My Project Does:

Enables even a layman to use advanced security toolset, like generating file checksums, verifying file integrity, chat with a tailored AI assistant, interact with external APIs, perform security scanning on networked devices, etc.

Target Audience:

Designed for students, computer security enthusiasts and cybersecurity analysts

Check out the presentation on Youtube: https://youtu.be/r6W2UaIsYzw?si=EzCQ3B71sSZpZT14

Link to source: https://github.com/NONAN23x/Octaprobe.git

Try out the demo app: https://octaprobe.streamlit.app/

/r/Python
https://redd.it/1ks0gs4
Django Admin/YouNameIt for frontend development?

Hi all,

As sysadmin and freelancer I am trying to find something that makes my life easier in the development of applications while having a nice look and feel for the application's frontend but also flexible to fullfill any project requirement.

Despite I know angular, I want to keep myself as far as possible from any "pure frontend framework" (react, angular, svelte, vue, etc).

I had a look to django unfold, jazzmin, jet, grapelly, adminlte, and some others but even when they usually fit most of the standard application usages, seems there is a consensous that use them as the frontend of your applications a very bad idea (eventhough I am using carefully the standard user/group/perms to restrict usage).

There is anything out there like those admin/templates that can be used confidently as a framework for my applications and help me improve my delivery times?

As an extra I would like to understand what are those good reasons why them are not recommended for frontend usage.

/r/django
https://redd.it/1ks1skr
Just launched Davia — like Lovable, but wired straight into your Python FastAPI backend

Hello,

I wanted to share a project I've working on that's called davia ai. I created it because I build all kinds of things with Python : functions, algorithms, bits of logic that do something useful. But then comes the hard part as a Python dev: letting other people actually use them - creating a frontend.

* **What My Project Does**

davia empowers developers to transform their Python applications—especially AI agents and internal tools—into interactive web apps with a dev mode on your local machine made for Python folks like us. The package integrates seamlessly with FastAPI, so all your existing endpoints, middleware, and practices still apply.

**The link is here** [https://github.com/davialabs/davia](https://github.com/davialabs/davia)

* **Comparison** (A brief comparison explaining how it differs from existing alternatives.)

**Streamlit / Gradio:** Great for quick ML demos but limited in flexibility—Davia gives you real FastAPI power with just as much ease.
**Flask / Django:** Powerful but heavy; Davia offers a lighter, faster path from Python script to full app without boilerplate.

* **Target Audience** (e.g., Is it meant for production, just a toy project, etc.)

Anyone building in Python that wants to create an appealing frontend.

Would love your feedbacks or comments on this, what could be improved.


Best,

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