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 good is flask(gunicorn) for production

I want to write a simple web app that serves as a form, it’ll accept sensitive personal info from the recipients. Issue is i’ve written flask for mostly personal websites and chatbots nothing too serious. Can flask scale and is it secure? or do I have to learn django?

I am aware that the web server provided with flask isn’t supposed to be used.

/r/flask
https://redd.it/1k3w02f
Settings.py for DRF

RESTFRAMEWORK = {
    "DEFAULT
AUTHENTICATIONCLASSES": (
        "rest
frameworksimplejwt.authentication.JWTAuthentication",
    ),
    "DEFAULT
PERMISSIONCLASSES": [
        "rest
framework.permissions.IsAuthenticated",
    ],
}

SIMPLEJWT = {
    "ACCESS
TOKENLIFETIME": timedelta(
minutes
=30),
    "REFRESH
TOKENLIFETIME": timedelta(
days
=1),
}


I just finished watching TechWithTim's django and react tutorial and am trying to work on my own project. More specifically for these two things above, what does the REST\
FRAMEWORK variable do, and is the SIMPLE_JWT variable how you usually set the lifetimes for the tokens. Thank you!

/r/django
https://redd.it/1k4ansn
Why was multithreading faster than multiprocessing?

I recently wrote a small snippet to read a file using multithreading as well as multiprocessing. I noticed that time taken to read the file using multithreading was less compared to multiprocessing. file was around 2 gb

Multithreading code

import time
import threading

def processchunk(chunk):
# Simulate processing the chunk (replace with your actual logic)
# time.sleep(0.01) # Add a small delay to simulate work
print(chunk) # Or your actual chunk processing

def read
largefilethreaded(filepath, chunksize=2000):
try:
with open(filepath, 'rb') as file:
threads = []
while True:
chunk =
file.read(chunksize)


/r/Python
https://redd.it/1k4cwbm
How do you manage Django Migration in a team

Hello everyone,

How do you manage migration files in your Django project in multiple developers are working in it?

How do you manage local copy, staging copy, pre-prod and production copy of migration files? What is practice do you follow for smooth and streamlined collaborative development?

Thanks in advance.

/r/djangolearning
https://redd.it/1k43p9z
Made a Python Mod That Forces You to Be Happy in League of Legends 😁

Figured some Python enthusiasts also play League, so I’m sharing this in case anyone (probably some masochist) wants to give it a shot :p

What My Project Does

It uses computer vision to detect if you're smiling in real time while playing League.
If you're not smiling enough… it kills the League process. Yep.


Target Audience

Just a dumb toy project for fun. Nothing serious — just wanted to bring some joy (or despair) to the Rift.


Comparison

Probably not. It’s super specific and a little cursed, so I’m guessing it’s the first of its kind.


Code

👉 Github

Stay cool, and good luck with your own weird projects 😎 Everything is a chance to improve your skills!

/r/Python
https://redd.it/1k4kx23
Anyone still using twisted in 2025.

are there companies still using python twisted library and what benefits it has over others . Does is still makes sense to use twisted for backend game servers?
https://github.com/twisted/twisted

/r/Python
https://redd.it/1k4en05
Personal Project. Preparation questions generator for CompTIA Security+

Hi guys,

I have been developing a tool with Flask to generate prep questions for Security+ for my own preparation, but it actually turned out so well so I decided to share it with people. Please have a look: https://github.com/ilya-smut/blue-book

It uses Google Gemini to generate questions. The questions are actually of high quality, and you can even specify the topic you want to focus on. It also checks your answers and tells you what you got right or wrong. I attach some screenshots.

Please let me know what you think about and feel free to use it for your own preparation or contribute to the project!

P.S. I know we are talking about Cyber Security here, so just wanted to clarify one thing. Gemini access token is saved locally on your machine in user home directory. You can see how it's done in save_config() function in the code.

You can generate 2, 5, 10, or 20 questions. You can change \/ add more values in code if you want to

Example with a topic to focus on specified

(https://preview.redd.it/tool-to-generate-comptia-security-preparation-questions-v0-xb1z3gc3a9we1.png?width=1722&format=png&auto=webp&s=a015c58ceb692c5cfaaa733d93df8cef04032d25)

Example of questions generated without topic specified

(https://preview.redd.it/tool-to-generate-comptia-security-preparation-questions-v0-3lhuqrcea9we1.png?width=1412&format=png&auto=webp&s=e1f4a9ffe7dcc221e0e8e4522d8076a2c1ab2e60)

Answers check

(https://preview.redd.it/tool-to-generate-comptia-security-preparation-questions-v0-y8ei0pysa9we1.png?width=1220&format=png&auto=webp&s=f9c9e2357a3aa363428921e407b2e0e59b5d8993)

/r/flask
https://redd.it/1k4pjsc
D What are the current research gaps on GNN?

I would like to know your suggestions since I’m very interested in GNN and also their explainability aspects, however I noticed the huge amount of literature in the last years and I don’t want to lose focus in the new aspects of potential research.

/r/MachineLearning
https://redd.it/1k4oxgo
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/1k4sm06
Make your module faster in benchmarks by using tariffs on competing modules!

Make your Python module faster! Add tariffs to delay imports based on author origin. Peak optimization!
https://github.com/hxu296/tariff

/r/Python
https://redd.it/1k4qhdd
Thread or process vs celery

I have a service a client connect with web socket. When the service get a connection, it will trigger a task that should run as long as the web socket connection is alive. The task is like doing something regularly every second, then update the client through the web socket so that the client can view it on the display.

How do I architect this? At first I thought I should use channel and celery to do the task but then it's not really like a traditional task a celery worker is supposed to do but it's rather very long running task almost like another service (running like 1 hr or as long as websocket is alive, and it should update the client in real time very second). Is it better to fork process/thread and run it on demand? If I use thread, how do I manage work thread and scale it out and down?

Is Django not appropriate here? I'll have the web page run with Django anyway.

/r/django
https://redd.it/1k4zc5u
6th Datathon - a Virtual Data Science Hackathon is happening this weekend

DubsTech UW is hosting a virtual Datathon this Saturday, April 26 and Sunday, April 27. Do join us if you love data analytics, data visualization, or machine learning and want to put your skills to the test. Our data science hackathon is 100% beginner friendly and you can use Python or any other tool to build your projects!

Get an opportunity to work on real world datasets and get feedback from our panel of 11 judges. So come build with friends, make new friends, learn new skills and compete with data lovers from around the world.

Register Here: https://datathon2025.webflow.io/

Date: April 26 & 27, 2025
Location: Zoom (Virtual)

/r/Python
https://redd.it/1k4b7lx
django-simple-captcha ? My form was a spam magnet

My contact form was getting so much spam I couldn't find real inquiries anymore.

I implemented django-simple-captcha and the spam completely disappeared. I customized it to match my dark theme (you can see it at https://www.eriktaveras.com/contact/) and it works perfectly.

But I'm wondering if it's the best long-term option.

What do you use? django-simple-captcha, Google reCAPTCHA, honeypot fields, or something else?

Have you noticed any impact on conversion rates with different options?

/r/django
https://redd.it/1k4ldy3
Need help with IIS please

Hi everyone,
I'm trying to deploy my Django web app to Window 2019 IIS server.
I follow this instruction:
https://www.youtube.com/watch?v=APCQ15YqqQ0&t=1123s
Function work, how ever, the static template file seem not work properly.
What's the properly problem?.
I try to install window server on my computer and follow instruction and it work.
Please advise .
Thank you

/r/django
https://redd.it/1k51vv9
Need Help in Creating a Full Stack This is my First tym Doing a Project

I'm Doing A Project on Multi Asset Portfolio management which takes and This is my First tym Doing a Full Stack Project and i Dont know How to Do it and there i Am Getting many Errors which i am Getting in Fetching Data and other Parts. Please help me in Completion of this Project and now i am trying to Integrate a Project with mine na i am getting erors wheni am Trying to run it

/r/flask
https://redd.it/1k4zpor
HELP

/r/djangolearning
https://redd.it/1k4zybv
1,000 Python exercises

Hi r/Python!

I recently compiled 1,000 Python exercises to practice everything from the basics to OOP in a level-based format so you can practice with hundreds of levels and review key programming concepts.

A few months ago, I was looking for an app that would allow you to do this, and since I couldn't find anything that was free and/or ad-free in this format, I decided to create it for Android users.

I thought it might be handy to have it in an android app so I could practice anywhere, like on the bus on the way to university or during short breaks throughout the day.

I'm leaving the app link here in case you find it useful as a resource:
https://play.google.com/store/apps/details?id=com.initzer\_dev.Koder\_Python\_Exercises

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