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
How do you design your project?

So, I'm currently in the process of learning back-end development. Knowing python from before, i decided on starting out with Django.

I was wondering how should i design me project. Like the layout (how many & what apps, models, etc). The first step i figured would be to list out all the features i would like in my project.

I'm stumped on what to do after this though.

So, can y'all tell me how you guys go about it?

Any tips & tricks would be very helpful as well.

/r/djangolearning
https://redd.it/1icm5u1
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/1igbnik
Pyttings – A Minimalist Python Settings Manager Inspired by Django

I wanted to share Pyttings, a lightweight Python settings manager with namespacing, modular files, and automatic type parsing. It’s inspired by Django’s settings but designed to be minimal and flexible.

GitHub: https://github.com/ruitcatarino/pyttings

# What My Project Does

Pyttings simplifies application configuration by allowing you to:

Namespaced Settings: Use a prefix (e.g., `PYTTING_`) to avoid conflicts.
Custom Prefix: Change the prefix using PYTTING_ENV_PREFIX.
Modular Settings: Load settings from a module with `PYTTING_SETTINGS_MODULE`.
Environment Variables: Override settings easily, with automatic type parsing.

# Target Audience

Pyttings is production-ready and ideal for:

Developers who want a simple, minimal settings manager.
Applications that need modular, environment-based configurations.
Users looking for an alternative to `pydantic-settings` or Django-style settings.

# Comparison

Compared to Django’s settings, Pyttings is framework-agnostic and much lighter.
Compared to `pydantic-settings`, Pyttings has:

A smaller footprint – no external dependencies.
Minimalist design – no validation, just simple settings management.
Explicit and easy-to-use API – define settings as plain Python variables.

Would love your feedback! Let me know what you think or if you have suggestions.

/r/Python
https://redd.it/1iga8kx
D Self-Promotion Thread

Please post your personal projects, startups, product placements, collaboration needs, blogs etc.

Please mention the payment and pricing requirements for products and services.

Please do not post link shorteners, link aggregator websites , or auto-subscribe links.

--

Any abuse of trust will lead to bans.

Encourage others who create new posts for questions to post here instead!

Thread will stay alive until next one so keep posting after the date in the title.

--

Meta: This is an experiment. If the community doesnt like this, we will cancel it. This is to encourage those in the community to promote their work by not spamming the main threads.

/r/MachineLearning
https://redd.it/1ifnw79
OAuth 2 authorisation flow with django-oauth-toookit

I have a vanilla JS SDK with a django backend. I want to implement the OAuth 2 Authorization flow with PKCE for users who will use the SDK. I am using django-oauth-toolkit for the same. I have to redirect the user to the Auth page where he can give permission. Then the redirect uri points to an endpoint in my django server and the code is exchanged for access token. Everything is fine till this point. But now, how do I let my SDK know that the auth flow is complete and now I can request for the access token from the backend and start using it.
NOTE: my SDK can be used in different pages, so there is no single source of origin for any request.

/r/djangolearning
https://redd.it/1igijvy
Found this cool Python WFP library that makes network filtering super easy in Windows!

Found this cool Python WFP library that makes network filtering super easy

Just discovered PyWFP while looking for a way to handle Windows Filtering Platform in Python. It's pretty neat - lets you create network filters with really simple syntax, similar to Windivert if anyone's familiar with that.

Quick example of what you can do:

from pywfp import PyWFP
pywfp = PyWFP()
filter_string = "outbound and tcp and remoteaddr == 192.168.1.3 and tcp.dstport == 8123"

with pywfp.session():
pywfp.add_filter(filter_string, filter_name="My Filter")

The syntax is really straightforward - you can filter by:

* TCP/UDP/ICMP

* IP ranges

* Specific ports

* Inbound/outbound traffic

Been playing with it for a bit and it works great if you need to programmatically manage Windows network filters. Thought others might find it useful!

Link: Github

/r/Python
https://redd.it/1ign06a
I need help with Fullcalendar Flask Project

For some reason events cannot be added on calendar, but if I were to add events manually (both on index.html or directly on database) it can be seen. Any ideas?

app.py: https://codefile.io/f/qrT0duwAmo

index.html: https://codefile.io/f/elAUexD7vK

/r/flask
https://redd.it/1igov0s
Django Updates: January 2025

hey all!

I wrote a small script that gets all the commits from django codebase on any given month and summarizes the changes. Then gives me the master summary for the whole month. The result is pretty cool 😄 I posted it [here](https://builtwithdjango.com/blog/django-jan-2025-updates) (with all the commit links), but will also paste below:

# Overview

The month showed significant development activity with 90 commits focusing on several major themes:

* Extensive work on composite primary key support and validation
* Bug fixes and improvements for database operations
* Documentation updates and cleanup
* Security and dependency updates
* Test suite improvements and optimization

# Key Changes and Features

Major Features

* Added automatic model imports to Django shell command, a GSoC 2024 project by Salvo Polizzi
* Implemented double squashing of migrations capability by Georgi Yanchev
* Added ability to customize admin password change form by Mohammadreza Eskandari

Composite Primary Key Improvements

* Added serialization support for composite primary keys by Sarah Boyce
* Fixed password reset functionality with composite primary keys by Sarah Boyce
* Added validation for non-local fields in composite primary keys by Bendeguz Csirmaz

Bug Fixes

* Fixed UnicodeEncodeError in email attachments by greg
* Fixed bulk\_update handling with multiple primary keys by Sarah Boyce
* Fixed RecursionError in FilteredRelation joins by Peter DeVita

Security and Dependencies

* Updated

/r/django
https://redd.it/1iglcck
How to use a normal python class in django?

So I need to use this class in my django application
https://github.com/open-spaced-repetition/py-fsrs/blob/main/fsrs/fsrs.py/#L88
Is it possible though? If not directly I was thinking making a wrapper that converts my django object to this, call a function on it to get the updated object and then convert it back to a django object and store in database, but it seems like extra processing work and I want to know if I can use this directly as a one to one key with django object.

/r/djangolearning
https://redd.it/1igyk8w
🚀 html-to-markdown 1.2: Modern HTML to Markdown Converter for Python

Hi Pythnoista's!

I'm excited to share with you [html-to-markdown](https://github.com/Goldziher/html-to-markdown).

This library started as a fork of [markdownify](https://pypi.org/project/markdownify/) - I used it when I wrote a webscaper and was frustrated with its lack of typing. I started off by adding a `py.typed` file, but found myself rewriting the entire library to add typing and more extensive tests, switching from its class based approach to a lighter, functional codebase.

## Target Audience

- Python developers working with HTML content conversion.
- Web scrapers needing clean Markdown output.
- Documentation tooling maintainers.
- Anyone migrating content from HTML to Markdown-based systems.

## Alternatives & Origins

This library is a fork of [markdownify](https://pypi.org/project/markdownify/), an excellent HTML to Markdown converter that laid the groundwork for this project. While markdownify remains a solid choice, this fork takes a different approach:

**html-to-markdown vs markdownify:**

- Full type safety with MyPy strict mode
- Functional API vs class-based architecture
- Modern Python 3.9+ support
- Strict semver versioning
- More extensive test coverage including integration tests
- Allows configuration of BeautifulSoup

**Other alternatives:**

- html2text: Popular but last updated 2020.
- tomark: Minimal features, no typing support.
- md-convert: Limited configuration options.
- Beautiful Soup's get_text(): Basic text extraction only.

## Quick Example

```python
from html_to_markdown import convert_to_markdown

markdown = convert_to_markdown('<b>Hello</b> <a href="https://reddit.com">Reddit</a>')
# Output: '**Hello** [Reddit](https://reddit.com)'
```

## Installation

```python
pip install html-to-markdown
```

Check out the [GitHub repository](https://github.com/Goldziher/html-to-markdown)

/r/Python
https://redd.it/1igtrtp
Text to Video Model Implementation Step by Step

# What My Project Does

I've been working on a text-to-video model from scratch using PyTorch and wanted to share it with the community! This project is designed for those interested in diffusion models.

# Target audience

For students and researchers exploring generative AI.

# Comparison

While not aiming for state of the art results, this serves as a great way to understand the fundamentals of text-to-video models.

# GitHub

Code, documentation, and example can all be found on GitHub:

https://github.com/FareedKhan-dev/text2video-from-scratch

/r/Python
https://redd.it/1iggbcu
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/1ih454j
[D] BERT Embeddings using HuggingFace question(s)

I am trying to find BERT embeddings of disassembled files with opcodes. Example of a disassembled file:
```
add
move
sub
... (and so on)
```

The file will contain several lines of opcodes. My goal is to find a embedding vector that represents the WHOLE file (for downstream tasks such as classification/clustering).

With BERT, there are two main things: the tokenizer and the actual BERT model. I am confused whether the context size of 512 is for the tokenizer or the actual model. The reason I am asking is, can I feed all the opcodes to the tokenizer (which could be thousands of opcodes), THEN separate them in chunks (with some overlap if needed), and then feed each chunk to the BERT model to find that chunk's embedding*? Or should I first split the opcodes into chunks THEN tokenize them?

This is the code I have so far:
```py
def tokenize_and_chunk(opcodes, tokenizer, max_length=512, overlap_percent=0.1):
"""
Tokenize all opcodes into subwords first, then split into chunks with overlap

Args:
opcodes (list): List of opcode strings
tokenizer: Hugging Face tokenizer


/r/MachineLearning
https://redd.it/1ih2ywl
From Django to FastAPI: Building a Warehouse Bin Location with Raspberry Pi / Shopify

Hey Reddit! I recently developed a warehouse management bin location tool for a company and wanted to share the process. The goal was simple: create a system where warehouse staff could scan a product’s SKU and instantly see its location, product details, and an image. But behind that simplicity was a fun technical journey.

I started with Django because it’s great for rapid prototyping. However, as the project evolved, I realized we needed something more lightweight for handling real-time API calls to Shopify. That’s when I switched to FastAPI. The async capabilities made a huge difference when querying Shopify’s GraphQL API, especially during peak hours. Plus, the automatic OpenAPI docs were a bonus for testing and debugging.

https://preview.redd.it/n2jvnf2yszge1.png?width=1918&format=png&auto=webp&s=5ffadee065996c307a9b8ec4e15cfdb06aab95c5

The hardware setup is where things got interesting. The system runs on a Raspberry Pi 4 connected to a 7-inch touchscreen and a USB numeric keypad (no full keyboard needed—just quick SKU entry). The Pi acts as both server and client, hosting a FastAPI backend and serving a minimalist Vue.js frontend. The interface is optimized for speed: workers scan a SKU, and the screen immediately displays the bin location and product image.

https://preview.redd.it/tviudj5sszge1.jpg?width=4032&format=pjpg&auto=webp&s=94b6c9d7ce130f57a4a6582198f8f6e263d8a35c

One big challenge was handling Shopify’s metafields. Products and variants store their

/r/django
https://redd.it/1ih0z8n
pytest-mock : Mocking in pytest - Test & Code

https://testandcode.com/episodes/pytest-mock

pytest-mock is currently the #3 pytest plugin.

- Why the pytest-mock plugin is awesome
- What is mocking, patching, and monkey patching
- What, if any, is the difference between mock, fake, spy, stub.
- Why we might need these in testing
- Some history of mock in Python and how mock became unittest.mock
- Using mocker.patch, mocker.spy, and mocker.stub
- Why pytest-mock is awesome and why you might want to use it over straight unittest.mock

/r/Python
https://redd.it/1ih5238
Introducing ElixirDB - Simplified SQLAlchemy Engine management - with extras.

Hello,

I'm building libraries (the previous one was similar to this) to get criticism to improve my code and logic because even as a professional developer, I've never had a senior engineer/dev. I took in some feedback from the previous library to make something potentially useful this time.

This is a pre-release, so there are some things I'm ironing out. Let me know what you guys think. Always looking for criticism.

Github: https://github.com/hotnsoursoup/elixirdb

Pypi: https://pypi.org/project/elixirdb/

What My Project Does:
ElixirDB simplifies interaction with SQLAlchemy, providing streamlined database operations, enhanced configuration management, and improved developer experience.

Target Audience:
Anyone that wants to stand up a quick database connection or may want the flexibility of switching engines from a central class. Perhaps you don't like the way sqlalchemy binds engines.

Comparison:
Not sure, I couldn't really find anything out there. I did try googling quite a bit and even asked 3 different AI models to find me one, but it didn't come up with anything. I'd love for any references.

# Key Features (Reduced, more on github/pypi)

* **Automatic loading:** Define an **elixir**.yaml file in your project, and it will be automatically loaded into the ElixirDB instance.
* **Pydantic Integration:** Define and validate database configurations using Pydantic models
* **Multi-Engine Support:** Seamlessly manage multiple database engines through

/r/Python
https://redd.it/1ih6bo6
R reasoning models are indecisive parrots

R1 , o1, and gemini 2.0 flash were put to the test on 27 different puzzles.

the models still default to familiar solutions rather than adapting to new contexts - they even impose nonexistent constraints, waste tokens, and arrive at the wrong answer. Examples:

Example 1

Question: A group of four people needs to cross a bridge at night. The bridge is very old and rickety. They have only one torch, and because it's nighttime, the torch is necessary to cross the bridge. Each person walks at a different speed:A takes 1 minute to cross,B takes 2 minutes,C takes 5 minutes, andD takes 10 minutes.What is the fastest time they can all get across the bridge?

Answer: 10 minutes, the speed of the slowest person as they cross the bridge together.

DeekSeek-R1: "...First, the constraints: the bridge can only hold two people at a time, and the torch is needed each time someone crosses. So, if two people go over together, one has to come back with the torch."

Example 2

Question: Suppose you're on a game show,

/r/MachineLearning
https://redd.it/1iheszs
Kindly give me an advice on seeking a job.

Hi,

I started learning coding on my own and worked as a freelancer developing static websites. Later, I picked up Python-Django and took a job as a Junior Software Developer on April 15, 2024.

On August 19, both of my parents were involved in a serious accident, and my father had to undergo multiple surgeries, with his last operation taking place on December 31. Since the company did not offer me a work-from-home option despite my repeated requests, they closed my file.

Now that I have fulfilled my responsibilities in taking care of my parents, I am actively looking for a job, but finding one has been challenging.

The skills I have developed include Python, Django Framework, REST APIs, SQL, MySQL, AWS, HTML, CSS, and Git.

Please provide me with advice on how to proceed.

/r/django
https://redd.it/1ihdx90
Optimizing data storage in the database

Hi All!


My Django apps pulls data from an external API and stores it in the app database. The data changes over time (as it can be updated on the platform I am pulling from) but for various reasons let's assume that I have to retain my own "synced" copy.

What is the best practice to compare the data I got from the API to the one that I have saved? is there a package that helps do that optimally? I have written some code (quick and dirty) that does create or update, but I feel it is not very efficient or optimal.


Will appreciate any advice.




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