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
R Cosine Similarity Isn't the Silver Bullet We Thought It Was

Netflix and Cornell University researchers have exposed significant flaws in cosine similarity. Their study reveals that regularization in linear matrix factorization models introduces arbitrary scaling, leading to unreliable or meaningless cosine similarity results. These issues stem from the flexibility of embedding rescaling, affecting downstream tasks like recommendation systems. The research highlights the need for alternatives, such as Euclidean distance, dot products, or normalization techniques, and suggests task-specific evaluations to ensure robustness.

Read the full paper review of 'Is Cosine-Similarity of Embeddings Really About Similarity?' here: https://www.shaped.ai/blog/cosine-similarity-not-the-silver-bullet-we-thought-it-was

/r/MachineLearning
https://redd.it/1i0hfsd
RichChk: Edit StarCraft maps in Python

# What My Project Does

My project, RichChk, allows directly editing all aspects of a StarCraft Brood War map in Python. This is to allow those who make StarCraft custom games / maps (they can be thought of as "mods") a powerful way to use modern software practices to maintain and iterate on their maps, without using clunky GUIs. I initially made this library for myself, as my own custom maps became too complicated to maintain using text macros and having to copy+paste script output to update the map each time I made changes to test it. I named my project RichChk from the binary file format maps are stored in called Scenario.chk and my library making it much richer and easier for a human to read/edit.

Some examples of custom StarCraft maps are Battle of Helms Deep or even a re-creation of Elder Scrolls IV Oblivion RPG. My library was not used to make those maps, but the idea is that going forward it is better to maintain and create such maps using this library.

RichChk is a fully statically typed codebase with 200+ unit tests. I use GitHub actions to automatically run

/r/Python
https://redd.it/1i0lwjo
Indentation-based syntax for Clojure

Indentation-based syntax for Clojure

What My Project Does

Provides indentation-based, Python-like syntax for Clojure.

Target Audience

Developers who want to try Clojure, but its syntax looks weird for them. It can be a starting point to dive into Clojure and its ecosystem. Due its indentation-based nature it can be interesting for Python developers. Also it can be interesting for programming languages designers and developers.

Comparison

Compared to Clojure syntax the project provides more familiar and traditional non-lisp syntax: C-style function call, infix notation for math operations, less parentheses.

Compared to Python the project provides more functional programming, Clojure/Java ecosystem.

/r/Python
https://redd.it/1i0k96j
Niquests 3.12 — What's new in 2025

The Requests fork http client is growing rapidly and soon to hit his 1st million pulls.
Since last time we published in this subreddit, we are proud to announce that:

- Made SSE (Server side event) consumption natively integrated.
- Brought HTTP/2+ WebSocket as a mainstream client.
- Within our Python ecosystem, we're the only one! Chrome & Firefox were capable ages ago!
- Upgraded our Kyber768Draft post quantum implementation to standard Module Lattice 768 (ML-KEM-768).
- Ensured free threaded support!
- Requests, and Niquests are the only trustworthy clients that can run on the experimental build.
- httpx was already crashing randomly when the GIL is enabled (mostly with http2). In the free threaded build, it crashes every single time (http1 or http2). Thus confirming the unsafe aspect of sharing httpx.Client between threads.
- Allowed caching of the OCSP revocation status, via pickling your Session.
- Using ping frames to keep alive (discretly) your HTTP/2+ connections perfectly, without ever leafting a finger.
- Wrote guides on how to get the smoothest upgrade between Requests and Niquests while keeping all your plugins (e.g. betamax, requests-mock, responses, requests-oauthlib, ...).

The project reached 1,1k+ stars thanks to you all.
I receive a lot of positive feedback either pivately (mostly

/r/Python
https://redd.it/1i09ip9
Questions about launching first public-facing django project

Hi all,

A few questions:


1. I'm about to launch a product in the next few months. I'm a blind developer, and want to make sure that my UI looks okay. Is there an easy way to give my django templates to someone I pay to make them look better without sharing the entire repo of code? I'm under a couple license restrictions and don't know how to handle that.

Finally, Are there reasonable t&c/ToS templates that are useful for copying without paying a lawyer $250/h? Anything else I should be concerned about in that realm when launching? Any pitfalls you ran into when launching a service?

Thanks,

/r/django
https://redd.it/1i0qqlq
drf-oauth-toolkit: a set of tools to simplify Oauth

# [drf-oauth-toolkit](https://github.com/basola21/drf-oauth-toolkit) – Pre-Demo Release

hello everyone

I’ve just released the **pre-demo version** of `drf-oauth-toolkit`, a Django REST Framework library aimed at simplifying **OAuth2 token management** and making authentication workflows more flexible for modern APIs.

# Why I Built This

OAuth integration has become a standard need in most modern projects, especially when working with providers like Google or Facebook. While there are already great libraries for Django such as:

* `django-oauth-toolkit` – A complete OAuth2 provider.
* `social-auth-app-django` – Powerful social authentication for multiple providers.
* `dj-rest-auth` – A convenient drop-in solution for registration and social auth.

I built `drf-oauth-toolkit` to solve **flexibility issues** I've encountered in real-world projects. Many existing libraries assume a fixed way of handling tokens and user management, which can be challenging when working with Django Rest Framework or non-standard token workflows.

# Key Problems I'm Addressing:

* **Complex Setup:** Some libraries require extensive boilerplate with limited flexibility.
* **Token Management Assumptions:** Fixed token storage strategies that may not fit every project.
* **DRF Optimization:** Some packages aren't designed for DRF-first workflows.

# What's Ready Now:

* Core token management and structure implemented.
* Built following DRF best practices for security and scalability.
* Designed for easy integration and extension.

# What's Next:

The foundation is ready, and I’m currently

/r/django
https://redd.it/1i0ikmf
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/1i0snf0
Keyboard shortcut to clear code shell output in Jupyter notebook not working

Hi everyone!
Can anyone help with the keyboard shortcut to clear the cell output in Jupyter notebook v7.2.2?
A simple Google search yields the shortcut as "O" / "Shift+O" as per different articles, but none of them works in v7.2.2 and the only way to go about it now seems as "right click -> clear cell output", which isn't optimal.

#jupyternotebook #python

/r/IPython
https://redd.it/1i0zwrk
djapy needs your Django wisdom: Help shape the testing infrastructure of this type-safe REST framework

Hey Django devs! I'm excited to share djapy - a framework I've built to simplify Django REST APIs with type safety. Now I need your expertise to make it production-grade.

Quick demo of what djapy does:
# Regular Django views but with superpowers
@djapify
def get_user(request) -> {200: UserSchema, 404: str}:
return request.user

@djapify
def create_post(request, data: BlogPostSchema) -> BlogPostSchema:
post = Post.objects.create(**data.model_dump())
return post # That's it! Fully typed, validated, and documented


Why Django devs might care:
- Native Django patterns - no new concepts to learn
- Pydantic validation + Django ORM = ❤️
- Endpoints feature and IDE autocompletion that actually works (PyCharm)
- OpenAPI/Swagger docs generated automatically, with a touch of dark mode
- Just pip install djapy and start coding

Now for the hard part - I need help setting up a proper testing infrastructure. Some questions keeping me up at night:

1. Testing Strategy:
- How do you test type hints in a Django package?
- Best practices for testing Pydantic models with Django?
- Integration tests vs Unit tests ratio?

2. Development Workflow:
- Which pre-commit hooks are must-haves?
- pytest vs unittest for a Django package?


/r/django
https://redd.it/1i0yljq
Leviathan: A Simple, Ultra-Fast EventLoop for Python asyncio

Hello Python community!

I’d like to introduce Leviathan, a custom EventLoop for Python’s asyncio built in Zig.

What My Project Does

Leviathan is designed to be:

- Simple: A lightweight alternative for Python’s asyncio EventLoop.

- Ultra-fast: Benchmarked to outperform existing EventLoops.

- Flexible: Although it’s still in early development, it’s functional and can already be used in Python projects.


Target Audience

Leviathan is ideal for:

- Developers who need high-performance asyncio-based applications.

- Experimenters and contributors interested in alternative EventLoops or performance improvements in Python.


Comparison

Compared to Python’s default EventLoop (or alternatives like uvloop), Leviathan is written in Zig and focuses on:

1. Simplicity: A minimalistic codebase for easier debugging and understanding.


2. Speed: Initial benchmarks show improved performance, though more testing is needed.


3. Modern architecture: Leveraging Zig’s performance and safety features.



It’s still a work in progress, so some features and integrations are missing, but feedback is welcome as it evolves!

Feel free to check it out and share your thoughts: https://github.com/kython28/leviathan

/r/Python
https://redd.it/1i0yb1m
How Russian hackers nearly killed my Django based business

My wife and I were hiking through the scenic hills of Belgium when I received a concerning email from Amazon Web Services (AWS). The email, titled "Amazon SES Complaint Review Period for AWS Account [\]", contained the following warning:

>Your current complaint rate is 0.5%. We measured this rate over the last 10,351 eligible emails you sent. We recommend that you maintain a complaint rate below 0.1%. If your complaint rate exceeds 0.5%, we might pause your ability to send additional email.

I use AWS Simple Email Service (SES) to send emails for my nonprofit organization, and this warning came as a shock. It indicated that recipients had flagged emails from my system as spam. This was unexpected because I only send emails to individuals who actively subscribe to the service. I never send unsolicited messages.

I run a small nonprofit, TheLifeSigns, which helps people living alone stay safe. Through my website, users can sign up with their email address and provide the email addresses of their chosen "buddies," such as friends or family members. The service sends daily emails with a “lifesign” button. If the user clicks the button, nothing happens. However, if they fail to respond, the system automatically alerts

/r/django
https://redd.it/1i15n7a
D Machine Learning Engineer vs AI Research Scientist: Future Prospects?

Some people say that AI research scientists (PhD holders) are pretty much irreplaceable because of their ability to push the boundaries of knowledge and come up with groundbreaking methods and algorithms. But let’s be real—tech companies don’t need a ton of researchers, especially if their work doesn’t directly boost profits.

On the flip side, Machine Learning Engineers are the ones putting those algorithms into action, scaling systems, and keeping production pipelines running—all things that directly bring in the $$$. That’s why some people think MLE roles will grow faster than AI research scientist roles in the future.

What do you think? Are there trends or experiences you’ve seen that suggest one of these roles will be more in demand down the line? I'm currently a PhD student by the way.

For a fair comparison, let’s assume both roles are at a FAANG company.

/r/MachineLearning
https://redd.it/1i18421
Shellphone - Terraria Player File Editor TUI

Hi! In the days i started working on a Terraria player file editor.

What my project does:

* View base stats and body colors on an ascii-art render of a character
* View all kinds of inventory slots(Inventory, Armor, Accessories...)
* Edit items in said inventories

I will keep it updated as there are lot of things that missing or buggy.

Github: [Shellphone](https://github.com/kokasmark/shellphone)

/r/Python
https://redd.it/1i16yuj
I made a Twitter bot that offers YT timestamps

What My Project Does

Tag @TimeStampBuddy on X (formerly Twitter) with the link to a YouTube video, and it will provide timestamps.

Target Audience

The actual target audience are devs that want to make twitter bots. It's free to use and it's free to run/host. Feel free to clone the repo and make your own changes. Let me know if there is any extra info I could provide.

Comparison

I'm not aware of any other live twitter bot that offers this service.

AskDexa (https://github.com/dexaai/xbot) is another live twitter bot repo. My code is much simpler, making it easier to adapt for others who want to make their own Twitter bots.


Github: https://github.com/Mihaiii/TimeStampBuddy

/r/Python
https://redd.it/1i1b7ry
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/1i1kdk3
Advice on Building a Scalable Backend for a Dynamic Content Platform? (I'm a total noob so any advice is greatly appreciated, thank you)

I’m working on a project that involves building a dynamic content platform with some pretty complex backend requirements. I want to make sure I approach this the right way and was hoping for some advice or insights from this community.

Here’s the general gist of what I need:

Dynamic Content Delivery: The platform will have a branching structure where users navigate through various levels, each dynamically populated based on specific metadata (e.g., tags, categories).
Database Scalability: The system will need to handle a growing database of assets (images, metadata, user submissions) that are retrieved based on user choices.
Admin Panel: I need a user-friendly admin interface to upload, tag, and manage content efficiently.
API Integration: The backend will need to serve content dynamically to a WordPress frontend via APIs.
Authentication: Secure login options, including third-party authentication (Google, Facebook, etc.).
Long-Term Growth: The system needs to be scalable to support thousands of entries and potentially high user traffic.

I’m considering technologies like Django or Node.js for the backend, paired with a relational database (e.g., PostgreSQL or MySQL). If you’ve worked on something similar or have any advice on structuring a project like this, I’d love to hear your thoughts.

Thanks in advance!

/r/django
https://redd.it/1i1l812
Develop web applications with wwwpy, which is scalable, customizable, and developer-friendly 🚀


This post announces the first installable version of wwwpy. It is still in its infancy, but I hope you will see the quality and direction of this Python framework for developing web applications.

Repository [https://github.com/wwwpy-labs/wwwpy](https://github.com/wwwpy-labs/wwwpy) 
Homepage https://wwwpy.dev/ 

Like any tool, libraries and frameworks have trade-offs. Some have poor trade-offs, limited strengths, and numerous weaknesses. The goal of wwwpy is to achieve an optimal trade-off: providing the best possible balance between ease of use and power. ⚖️

How do wwwpy achieve this? By utilizing all available technologies without restricting or obscuring access to them. With wwwpy, you can leverage pre-built UI components to rapidly build interfaces. Still, if you need more control, the browser's DOM, HTML, and CSS technologies are fully accessible. 🎨

At its core, wwwpy aims to ease access to technology rather than hinder it. For example, when you create a component, you're effectively working with standard HTML custom Web Components, extending familiar technologies rather than reinventing the wheel. 🛠️

What My Project Does

Develop web applications quickly, Python all the way down.

The vision of wwwpy:

Jumpstart Your Projects: With just a couple of commands, get a head start on building web UIs, allowing you to focus on coding and scaling your application.


/r/Python
https://redd.it/1i12yib
I created an opensource lightweight django-cookiecutter

Hi!

TLDR: I created a template to create typical Django projects faster. Details on how to use it in the repo.

I often (2-6 times a year) create Django projects. They always use Django-celery, DRF and connected to postgreSQL. Coupling these together always take \~1hr of my time.

To save these hours I created a Django template cookiecutter \- now setting up a Django app takes seconds instead of hours.

Template creates you a Django application with

1. Django-Rest-Framework
2. Django-celery-beat to do async jobs in the background
3. PostgreSQL as database
4. Everything dockerized

Why not use the official Django cookie cutter?

Because it is just too much. When I tried to use it it took more time to remove unnecessary staff - it contains bootstrap, all sorts of pluggable libraries - precommits, allauth, anymail etc...

I hope this might help someone :)

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