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
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
I rewrote my programming language from Python into Go to see the speed up.

What my project does:

I wrote a tree-walk interpreter in Python a while ago and posted it here.



Target Audience:

Python and programming entusiasts.

I was curious to see how much of a performance bump I could get by doing a 1-1 port to Go without any optimizations.

Turns out, it's around 10X faster, plus now I can create compiled binaries and include them in my Github releases.

Take my lang for a spin and leave some feedback :)


Utility:

None - It solves no practical problem that is not currently being done better.

/r/Python
https://redd.it/1i1ppr7
I have 0 experience in Django but have to Interview Candidates. Help!

Hi every one I an working in a company where we have just received a project in Django or are about to. But no one in the company has experience in Django development.



So HR has given me the job of handling Django interviews as I am the only one who has some knowledge Django and python but no work experience.



Can u guys give me some Questions and coding exercises that I can ask the candidate to know if they are suitable for the job. I have not been told about if we have to hire Junior or Senior devs.


Thanks to all the answers.

/r/django
https://redd.it/1i1ssz1
R Transformer²: Self-Adaptive LLMs

Paper: https://arxiv.org/abs/2501.06252

Abstract

Self-adaptive large language models (LLMs) aim to solve the challenges posed by traditional fine-tuning methods, which are often computationally intensive and static in their ability to handle diverse tasks. We introduce Transformer², a novel self-adaptation framework that adapts LLMs for unseen tasks in real-time by selectively adjusting only the singular components of their weight matrices. During inference, Transformer² employs a two-pass mechanism: first, a dispatch system identifies the task properties, and then task-specific "expert" vectors, trained using reinforcement learning, are dynamically mixed to obtain targeted behavior for the incoming prompt. Our method outperforms ubiquitous approaches such as LoRA, with fewer parameters and greater efficiency. Transformer² demonstrates versatility across different LLM architectures and modalities, including vision-language tasks. Transformer² represents a significant leap forward, offering a scalable, efficient solution for enhancing the adaptability and task-specific performance of LLMs, paving the way for truly dynamic, self-organizing AI systems.

Blog Summary: https://sakana.ai/transformer-squared/

GitHub: https://github.com/SakanaAI/self-adaptive-llms

/r/MachineLearning
https://redd.it/1i1l8d4
Deploy React/Django in GCP Compute

Hi, did anyone have a detailed guide on how can I deploy my App using google compute? I have tried but unable to expose my app in port 3000 and 8000. Any help please. Thanks.

/r/django
https://redd.it/1i1oiwj
Running Django’s test suite for the first time problem

https://preview.redd.it/yikxryyv76de1.png?width=690&format=png&auto=webp&s=abb125ae95949ec2c4bcbef6c905f04bd1a003db

Hi. I found an instruction to run test suite for the first time here:
https://docs.djangoproject.com/en/dev/intro/contributing/
i have done everything written there but have some issues:
One of the tests (last on the screen) runs for a very long time and does not change its state
Can anyone suggest - what could be the problem?

/r/django
https://redd.it/1i1z193
I've Created a Python Library That Tracks and Misleads Hackers

Background

Hello everyone! A few months ago, I created a small web platform. Since I have many security engineer followers, I knew they would actively search for vulnerabilities. So, I decided to plant some realistic-looking fake vulnerabilities for fun. It was fun, and I realized that it can be actually very useful in other projects as well. I could monitor how many people were probing the platform while having them waste time on decoy vulnerabilities. Therefore, I've created BaitRoute: https://github.com/utkusen/baitroute

What My Project Does

It’s a web honeypot project that serves realistic, vulnerable-looking endpoints to detect vulnerability scans and mislead attackers by providing false positive results. It can be loaded as a library to your current project. It currently supports Django, FastAPI and Flask frameworks. When somebody hits a decoy endpoint, you can send that alarm to another service such as Sentry, Datadog, etc. to track hackers. Also, if you enable all rules, attackers' vulnerability scans become a mess with false-positive results. They'll waste considerable time trying to determine which vulnerabilities are genuine.

Target Audience

It can be used in web applications and API services.

Comparison

I’m not aware of any similar projects.



/r/Python
https://redd.it/1i208uo
Dash app down , 502 error randomly

I’ve deployed a dash app on one of my corporate servers (linux) and i have users complaining from application being down for no reason. (502 error)

Anyone has an idea about this issue ? maybe a tiemout from dash ?

THANKS

/r/flask
https://redd.it/1i21gni
Hard to master topics in Django

Recently I have been using Django quite alot I have about 2 years of experience in it now and I can almost always think of a solution in django when implementing new features, so I am starting to think that I am entering a comfort zone and not really learning new things.

So I wanted to get recommendations about features or changes that people may have struggled with and if I like something I may end up implementing it.

Thank you all for the suggestions.

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