pythondaily | Education

Telegram-канал pythondaily - Python Daily

1102

Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels

Subscribe to a channel

Python Daily

I built a minimal, type-safe dependency injection container for Python

Hey everyone,

Coming from a Java background, I’ve always appreciated the power and elegance of the Spring framework’s dependency injection. However, as I began working more with Python, I noticed that most DI solutions felt unnecessarily complex. So, I decided to build my own: Fusebox.

What My Project Does Fusebox is a lightweight, zero-dependency dependency injection (DI) container for Python. It lets you register classes and inject dependencies using simple decorators, making it easy to manage and wire up your application’s components without any runtime patching or hidden magic. It supports both class and function injection, interface-to-implementation binding, and automatic singleton caching.

Target Audience Fusebox is intended for Python developers who want a straightforward, type-safe way to manage dependencies—whether you’re building production applications, prototypes, or even just experimenting with DI patterns. If you appreciate the clarity of Java’s Spring DI but want something minimal and Pythonic, this is for you.

Comparison Most existing Python DI libraries require complex configuration or introduce heavy abstractions. Fusebox takes a different approach: it keeps things simple and explicit, with no runtime patching, metaclass tricks, or bulky config files. Dependency registration and injection are handled with just two decorators—@component and @inject.

Links:

[GitHub](https://github.com/ftbits/fusebox)
PyPI

Feedback, suggestions, and PRs are very welcome!

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

Читать полностью…

Python Daily

Django monolith + microservice (chat) setup — need input on auth flow

We built a Django + DRF monolithic SaaS app about 3 years ago that handles:

* User authentication (CustomUser)
* Subscription plans via Razorpay
* Users sign up, pay, and access features

Now we want to add a **chat feature** that interacts with **WhatsApp Web**. Here's our current plan:

* Create a separate **chat microservice** hosted on another subdomain (new VM)
* Use **React** frontend + **Django/DRF + Postgres** backend
* The chat microservice will:
* Use the **existing monolith for authentication**
* Maintain its **own database** for chat-related models
* Have a model like `ExternalCustomUser` which stores the `UUID` of the user from the monolith

The **React frontend** will interact with:

1. **Monolith backend** (for login/auth only)
2. **Chat microservice backend** (for all chat features)

# My questions:

1. Since login happens only once via the monolith, is the **authentication latency** negligible and acceptable?
2. After login, when the React app sends the auth token to the chat microservice, will the **chat DRF backend need to validate that token with the monolith on every request**, or is there a cleaner way to handle this?
3. Also, since the chat microservice doesn’t have a native `User` model (only an `ExternalCustomUser` with UUIDs), how should I handle`request.user`in DRF views?

/r/django
https://redd.it/1lw4pa4

Читать полностью…

Python Daily

Using OOP interfaces in Python

I mainly code in the data space. I’m trying to wrap my head around interfaces. I get what they are and ideally how they work. They however seem pretty useless and most of the functions/methods I write make the use of an interface seem useless. Does anyone have any good examples they can share?

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

Читать полностью…

Python Daily

Free-threaded (multicore, parallel) Python will be fully supported starting Python 3.14!

Python had experimental support for multithreaded interpreter.

Starting in Python 3.14, it will be fully supported as non-experimental: https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-pep779

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

Читать полностью…

Python Daily

Best options for deploying Flask app for a non-techie

I have just built a Flask app on my home desktop. It uses a mySQL database and integrates into a payment widget which uses webhooks as part of its payment confirmation. Other than this it is fairly straight forward. Some pandas, some form data collection.

In terms of hosting, I need it to be on all the time, but I anticipate it will not have heavy traffic, nor will the space requirement be particularly large. I would like to integrate it into my existing website - I.e. access the app via my existing website URL.

Some cost to host is fine, but low is better, particularly given low usage and space requirements.

I am not particularly technical, so ease of deployment is quite important for me.

Please could you suggest some possible services / strategies I could employ to deploy this.


TIA

/r/flask
https://redd.it/1luxr0d

Читать полностью…

Python Daily

10 underrated Django packages
https://wagtail.org/blog/10-underrated-django-packages/

/r/django
https://redd.it/1lvhrpf

Читать полностью…

Python Daily

Python Hackathon Backend for rapid development and Feedback-Driven shipping

Within a year, I had the opportunity to participate in hackathons organized by Mistral, OpenAI, and DeepMind in Paris. Leveraging this experience, I’ve created a Python-backend boilerplate incorporating my feedback to streamline collaboration and urgent deployments.

What it does: This open-source GitHub template provides a standardized and efficient boilerplate to expedite setup, collaboration, and rapid deployment during hackathons. The template encompasses several essential components, including the uv package manager complemented by intuitive pre-configured make commands, FastAPI for rapid and modular API development, and Pydantic for robust data validation and type checking. Additionally, it incorporates custom instructions optimized for agent tools like Cline and GitHub Copilot, enhancing both developer productivity and code comprehension. Comprehensive unit tests and a minimal Continuous Integration (CI) configuration ensure seamless integration and prevent merging faulty code into production.

Target audience: This project is specifically targeted at software developers and AI engineers, particularly those preparing for their first hackathon experience, whether working individually or within a collaborative team environment. It caters to developers looking for rapid prototyping and deployment solutions, emphasizing efficiency, maintainability, and robustness under tight deadlines and challenging operational conditions.

Comparison: While numerous boilerplate templates and rapid-deployment solutions exist in the Python ecosystem, this template distinguishes itself by specifically addressing the common

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

Читать полностью…

Python Daily

Local labs for real-time data streaming with Python (Kafka, PySpark, PyFlink)

I'm part of the team at [Factor House](https://factorhouse.io/), and we've just open-sourced a new set of free, hands-on labs to help Python developers get into real-time data engineering. The goal is to let you build and experiment with production-inspired data pipelines (using tools like Kafka, Flink, and Spark) all on your local machine, with a strong focus on Python.

You can stop just reading about data streaming and start building it with Python today.

🔗 **GitHub Repo:** [https://github.com/factorhouse/examples/tree/main/fh-local-labs](https://github.com/factorhouse/examples/tree/main/fh-local-labs)

We wanted to make sure this was genuinely useful for the Python community, so we've added practical, Python-centric examples.

**Here's the Python-specific stuff you can dive into:**

* 🐍 **Producing & Consuming from Kafka with Python (Lab 1):** This is the foundational lab. You'll learn how to use Python clients to produce and consume Avro-encoded messages with a Schema Registry, ensuring data quality and handling schema evolution—a must-have skill for robust data pipelines.

* 🐍 **Real-time ETL with PySpark (Lab 10):** Build a complete Structured Streaming job with `PySpark`. This lab guides you through ingesting data from Kafka, deserializing Avro messages, and writing the processed data into a modern data lakehouse table using Apache Iceberg.

* 🐍 **Building Reactive Python Clients (Labs 11

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

Читать полностью…

Python Daily

R Adopting a human developmental visual diet yields robust, shape-based AI vision

Happy to announce an exciting new project from the lab: “Adopting a human developmental visual diet yields robust, shape-based AI vision”. An exciting case where brain inspiration profoundly changed and improved deep neural network representations for computer vision.

Link: https://arxiv.org/abs/2507.03168

The idea: instead of high-fidelity training from the get-go (the de facto gold standard), we simulate the visual development from newborns to 25 years of age by synthesising decades of developmental vision research into an AI preprocessing pipeline (Developmental Visual Diet - DVD).

We then test the resulting DNNs across a range of conditions, each selected because they are challenging to AI:

1. shape-texture bias
2. recognising abstract shapes embedded in complex backgrounds
3. robustness to image perturbations
4. adversarial robustness.

We report a new SOTA on shape-bias (reaching human level), outperform AI foundation models in terms of abstract shape recognition, show better alignment with human behaviour upon image degradations, and improved robustness to adversarial noise - all with this one preprocessing trick.

This is observed across all conditions tested, and generalises across training datasets and multiple model architectures.

We are excited about this, because DVD may offers a resource-efficient path toward safer, perhaps more human-aligned AI vision. This work suggests that biology, neuroscience, and psychology have much to offer

/r/MachineLearning
https://redd.it/1luz9wu

Читать полностью…

Python Daily

Lost Chapter of Automate the Boring Stuff: Audio, Video, and Webcams

https://inventwithpython.com/blog/lost-av-chapter.html

The third edition of Automate the Boring Stuff with Python is now available for purchase or to read for free online. It has updated content and several new chapters, but one chapter that was left on the cutting room floor was "Working with Audio, Video, and Webcams". I present the 26-page rough draft chapter in this blog, where you can learn how to write Python code that records and plays multimedia content.

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

Читать полностью…

Python Daily

How to learn Django?

Do I follow documentation or a youtube series or anything else. I have been following the python roadmap on roadmap.sh and i am planning on learning django as my main framework for python.

P.S: I suck at reading documentation, so if you can suggest how to read documentations too.

/r/django
https://redd.it/1luvtga

Читать полностью…

Python Daily

Project Using LDV-style compression to create an innovation machine

I'm experimenting with a method to increase the conceptual density of ideas by compressing science and engineering concepts into minimal-vocabulary statements using the Longman Defining Vocabulary (LDV) - the core 2,000 building block words of the English language.

The hypothesis: reducing lexical complexity increases the chance that a language model will recombine latent structural similarities between otherwise distant concepts, when prompted accordingly ( I've got a whole program on these prompts as well).

That is, I'm trying to build a genuine innovation machine, bit by byte.

Rather than maximizing fluency, the goal is to preserve mechanistic structure using ~2,000 basic English words. This trades off precision and abstraction in favor of semantic alignment, similar to how concept bottlenecks work in neuro-symbolic systems.

The Why:

LLMs today are surprisingly poor at discovering cross-domain connections. When pushed, they tend to revert to well-trodden academic hallucinations, the kinds you find in introductions and conclusions of academic papers.

A compressed lexical environment, like LDV, exposes the mechanical spine of each idea. The hope is that this makes unexpected adjacencies more accessible.

Examples:

LDV-style input: 3 mechanisms

1. “A bucket with a hole lets water out slowly.”
→ time-delay or pressure bleed-off

2. “A button lets water go from one part to another.”
→ valve or

/r/MachineLearning
https://redd.it/1lun8s3

Читать полностью…

Python Daily

Tired of forgetting local git changes? I built a tool to track the status of all your local repos at

As someone who juggles many small projects—both personal and for clients—I often find myself with dozens of local git repositories scattered across my machine. Sometimes I forget about changes I made in a repo I haven’t opened in a few days, and that can lead to lost time or even lost work.



To solve this, I built gits-statuses: a simple tool that gives you a bird’s-eye view of the status of all your local git repositories.



It scans a directory (recursively) and shows you which repos have uncommitted changes, unpushed commits, or are clean. It’s a quick way to stay on top of your work and avoid surprises.



There are two versions:

Python: cross-platform and easy to integrate into scripts or cron jobs
PowerShell: great for Windows users who want native terminal integration

Check it out here: https://github.com/nicolgit/gits-statuses

Feedback and contributions are welcome!

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

Читать полностью…

Python Daily

Radiate - evolutionary/genetic algorithm engine

Hello! For the past 5 or so years I've been building `radiate` \- a genetic/evolutionary algorithm written in rust. Over the past few months I've been working on a python wrapper using pyo3 for the core rust code and have reached a point where I think its worth sharing.

**What my project does**:

* Traditional genetic algorithm implementation.
* Single & Multi-objective optimization support.
* Neuroevolution (graph-based representation - [evolving neural networks](http://www.scholarpedia.org/article/Neuroevolution)) support. Simmilar to [NEAT](https://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf).
* Genetic programming support ([tree-based representation](https://en.wikipedia.org/wiki/Gene_expression_programming#:~:text=In%20computer%20programming%2C%20gene%20expression,much%20like%20a%20living%20organism.))
* Built-in support for parallelism.
* Extensive selection, crossover, and mutation operators.
* Opt-in speciation for maintaining diversity.
* Novelty search support. (This isn't available for python quite yet, I'm still testing it out in rust, but its looking promising - coming soon to py)

**Target Audience** 
Production ready EA/GA problems.

**Comparison** I think the closest existing package is [PyGAD](https://pygad.readthedocs.io/en/latest/). I've used PyGAD before and it was fantastic, but I needed something a little more general purpose. Hence, radiate's python package was born.

**Source Code**

* [Github](https://github.com/pkalivas/radiate).
* [User Guide](https://pkalivas.github.io/radiate/).
* [Python specific examples](https://github.com/pkalivas/radiate/tree/master/py-radiate/examples).

I know EA/GAs have a somewhat niche community within the AI/ML ecosystem, but hopefully some find it useful. Would love to hear any thoughts, criticisms, or suggestions!

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

Is this safe to use ?

Hi everyone, i am curious about this code below.

re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),


it usually solves my problem where i turned of the debug my django system, is it safe?

/r/django
https://redd.it/1lvjzdy

Читать полностью…

Python Daily

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/1lvyekp

Читать полностью…

Python Daily

Devs in Johannesburg

Hi All,

The company I work for is hiring devs in Johannesburg South Africa.

Specifically a Senior Developer and Jnr Developer who can be in office in Johannesburg.

But we are struggling to find good hires, anyone know where to find the best Django devs in Joburg?

Cheers!

/r/django
https://redd.it/1lvkmxb

Читать полностью…

Python Daily

How to delete saved sessions if I'm using flask-session with sqlalchemy?

I'm currently using flask-session with sqlalchemy, and would like to delete all the sessions stored on my database when a user sends a specific request to an endpoint in my server. I thought I could use session.clear() for that, but it's not working.

This is my repo if you want to see it

/r/flask
https://redd.it/1lux7t4

Читать полностью…

Python Daily

D Trains a human activity or habit classifier, then concludes "human cognition captured." What could go wrong?

A screenshot of an article's title that was published on the Nature journal. It reads \\"A foundation model to predict and capture human cognition\\"

The fine-tuning dtaset, from the paper: "trial-by-trial data from more than 60,000 participants performing in excess of 10,000,000 choices in 160 experiments."

An influential author in the author list is clearly trolling. It is rare to see an article conclusion that is about anticipating an attack from other researchers. They write "This could lead to an 'attack of the killer bees', in which researchers in more-conventional fields would fiercely critique or reject the new model to defend their established approaches."

What are the ML community's thoughts on this?

/r/MachineLearning
https://redd.it/1lvcs2k

Читать полностью…

Python Daily

Problems with rabbitmq and pika

Hi everyone, I am creating a microservice in Flask. I need this microservice to connect as a consumer to a simple queue with rabbit. The message is sended correctly, but the consumer does not print anything. If the app is rebuilded by flask (after an edit) it prints the body of the last message correctly. I don't know what is the problem.

# [app.py](http://app.py)

from flask import Flask
import threading
from components.message_listener import consume
from controllers.data_processor_rest_controller import measurements_bp
from repositories.pollution_measurement_repository import PollutionMeasurementsRepository
from services.measurement_to_datamap_converter_service import periodic_task
import os

app = Flask(__name__)

PollutionMeasurementsRepository()

def config_amqp():
    threading.Thread(target=consume, daemon=True).start()

if __name__ == "__main__":
    config_amqp()  
    app.register_blueprint(measurements_bp)
    app.run(host="0.0.0.0",port=8080)

# message_listener.py

import pika
import time


def callback(ch, method, properties, body):


/r/flask
https://redd.it/1lve5rn

Читать полностью…

Python Daily

What terminal is recommended?

Hello. Im pretty new to this and been searching for good terminals. What kind of terminals would you recommend for begginers on Windows?

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

Читать полностью…

Python Daily

I've written a post about async/await. Could someone with deep knowledge check the Python sections?

I realized a few weeks ago that many of my colleagues do not understand async/await clearly, so I wrote a blog post to present the topic a bit in depth. That being said, while I've written a fair bit of Python, Python is not my main language, so I'd be glad if someone with deep understanding of the implementation of async/await/Awaitable/co-routines in Python could double-check.

https://yoric.github.io/post/quite-a-few-words-about-async/

Thanks!

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

Читать полностью…

Python Daily

Beginner's Guide

Hello! I have finished learning Python. I want to make a website on Django. Please, recommend beginner's guide: books or web resources that thoroughly discuss website creation. I liked A Complete Beginner's Guide to Django (2017) by Vitor Freitas. Completed the whole thing and deploy one training site. But maybe there are more up-to-date instructions/books. Thank you! P.S. Django documentation is always open.

/r/django
https://redd.it/1lv7g7l

Читать полностью…

Python Daily

Favorite ML paper of 2024? D

What were the most interesting or important papers of 2024?

/r/MachineLearning
https://redd.it/1luvynh

Читать полностью…

Python Daily

PatchMind: A CLI tool that turns Git repos into visual HTML insight. no cloud, no bloat

# What My Project Does

**PatchMind** is a modular Python CLI tool that analyzes local Git repos and generates a self-contained HTML report. It highlights patch-level diffs, file tree changes, file history, risk scoring, and blame info — all visual, all local, and no third-party integrations required.

# Target Audience

Primarily intended for developers who want fast, local insight into codebase evolution — ideal for solo projects, CI pipelines, or anyone sick of clicking through slow Git web UIs just to see what changed.

# Comparison

Unlike tools like GitHub’s diff viewer or GitKraken, PatchMind is entirely local and focused on generating reports you can keep or archive. There’s no sync, no telemetry, and no server required — just run it in your terminal, open the HTML, and you’re good.

It’s also **zero-config**, supports **risk scoring**, and can show **inline blame summaries** alongside patch details.

**How Python Is Involved**
The entire tool is written in Python 3.10+, using:

* `GitPython` for Git interaction
* `jinja2` for templating HTML
* `pyyaml`, `rich`, and `pytest` for config, CLI output, and tests

**Install:**

pip install patchmind

**Source Code:**
🌐 [GitHub - Darkstar420/patchmind](https://github.com/Darkstar420/patchmind)

Let me know what you think — or just use it and never look back. It’s under Apache-2.0, so

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

Читать полностью…

Python Daily

D Stop building monolithic AI agents - Pipeline of Agents pattern

Context: Needed to build scan → attack → report workflow for cybersecurity. First attempt was typical "everything in one graph" disaster.

The mess: One LangGraph trying to do everything. Unmaintainable. Untestable. Classic big ball of mud but with AI.

The fix: Pipeline of Agents

Sequential execution with clean interfaces
State isolation between child graphs
Each agent independently developable/testable
Follows actual software engineering principles

Technical details: Used LangGraph wrapper nodes to convert parent state to child state. Only pass minimal required data. No global state sharing.

Result: Actually maintainable AI architecture that doesn't make you hate your life.

Full breakdown with Python implementation: https://vitaliihonchar.com/insights/how-to-build-pipeline-of-agents

Question: Are others finding similar patterns necessary as AI systems get more complex?

/r/MachineLearning
https://redd.it/1lumxa6

Читать полностью…

Python Daily

Caching in Django

jegisew21/caching-in-django-f37d0916eae3">jegisew21/caching-in-django-f37d0916eae3" rel="nofollow">https://medium.com/@jegisew21/caching-in-django-f37d0916eae3

/r/django
https://redd.it/1lujl2y

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…
Subscribe to a channel