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
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/1f237eq
If you could go back, would you still learn django?

If you could go back to yourself when you were picking what framework to learn, would you still choose django? if not why and what would the other framework be?

/r/django
https://redd.it/1f25vtp
Does anyone know how secure Turso, or other cloud database providers are?

I have an established Saas product that deals with government protected personal data.

Right now, all of my data is held in an AWS RDS database, with AWS best security practices implemented. The app it self is run on an EC2 instance (I use ec2 because the entire application is configured with Nix, and there aren't any better solutions for it.)

It's a really read heavy application, so I was considering moving over to Turso, and using an embedded sqlite database. This should increase read speeds and reduce my cost to operate.

My only concern is that my clients are extremely security concerned. The embedded databases should be completely safe, but I'm concerned about traffic between my service and Turso.

Does anyone have any experience or advice they can share

/r/django
https://redd.it/1f200r6
Google SSO redirect URI

Hi there!

I recently deployed my backend on python anywhere and changed my auth uri in google console from localhost to python anywhere backend and it’s been few jours now and I am still getting 400 error and points to localhost.

Everything was working fine locally but there was a note in the console that says it may take “5min or upto few hours” to reset it so anyone has any idea about it?



/r/django
https://redd.it/1f27kq8
Used Python to create public-domain US maps that can serve as desktop backgrounds

[Link to source code (released under the MIT license)](https://github.com/kburchfiel/desktop_maps/blob/main/desktop_maps.ipynb)

[Link to main GitHub project](https://github.com/kburchfiel/desktop_maps) (scroll down on this page to view previews of these maps)

[Link to public-domain maps](https://github.com/kburchfiel/desktop_maps/tree/main/maps)

* **What My Project Does:** This project uses GeoPandas, Folium, Selenium, and Pillow to import public-domain shapefiles that I downloaded from the US Census website; convert them into maps; and then generate cropped screenshots of these maps. (Because I prefer dark desktops in order to reduce eye strain, these maps use mostly a black-and-orange color scheme.)
* **Target Audience**: anyone can use these maps for their desktop backgrounds. The source code may be of particular interest to anyone who uses (or wants to use) Python for mapping tasks.
* **Comparison**: Because these maps use only public-domain data, I was able to release them into the public domain. I imagine that many similar maps use more restrictive licenses.




/r/Python
https://redd.it/1f29mo0
Linking two different flask applications

I have two different flask applications test1.py and test2.py. I have a next button in test.py and when I click on it I want it to take me to test2.py. How do I do that?

I'm running them on different ports and using a redirect command. However, I'm getting site error every time I try to do it.

How can I resolve it?

/r/flask
https://redd.it/1f28nqo
🐍✂️ CSV Trimming: a one-line to clean up (most) messy CSVs! ✂️🐍

Hi r/Python!

Last week, I shared my **ugly-csv-generator** tool with this community, and the response blew me away! 🙌 Thank you so much for the support!

As I promised during the last post, I composed a decent set of heuristics that can often address those hideous CSV monstrosities. So I’m back with a Python package that does just that: **CSV Trimming**.

# 🔧 What My Project Does

[**CSV Trimming**](https://github.com/LucaCappelletti94/csv_trimming) is a Python package designed to take messy CSVs — the kind you get from scraping websites, legacy systems, or poorly managed data — and transform them into clean, well-formatted CSVs with just **one line of code**. No need for complex setups or large language models. It’s simple, straightforward, and generally gets the job done.

# 🛠️ Target Audience

This package is made by a data wrangler for data wranglers. It is not made for people who make terrible CSVs, it is made for those who have to deal with them.

Whether you're dealing with:

* Duplicated schema headers
* Corrupted NaN-like data entries (hello, `#RIF!`, I'm looking at you)
* Or even padding and partial rows...

**CSV Trimming** can handle it all. It's like Marie Kondo for your CSVs — if it doesn’t spark joy, it gets trimmed!

# 📦 Installation

As

/r/Python
https://redd.it/1f2bwx5
Django login

/r/djangolearning
https://redd.it/1f2daqg
Css not updating in django

I connected the html and css files with each other and linked the website

But when i update the css from the django project,it does not update the css

I then copied the html and css files and ran independentally without django(integrated) through live server

I saw the updated website,what can be the problem?

/r/django
https://redd.it/1f2g9kl
Modules that perform JIT at runtime

I have been trying to develop high performance functions in Python, and I am looking for packages that can compile blocks of code. I am aware of packages like Nuitka, MyPyc etc, I used them before and they work wonderfully (I especially like mypyc), however I now need to develop code for a large code base and we are restricted to pushing exclusively .py packges.

To overcome this issue I used numba a little bit, works really well but it's extremely limited in its usage. I wonder if there was any other package out there that let's you compile a function at runtime by just decorating it.

/r/Python
https://redd.it/1f2csus
h5 file machine learning, flask to kivy

Hi there!

I’m currently developing a Kivy app for sign language detection, and I’ve already trained a model using TensorFlow. I’m interested in using Flask to handle model predictions and integrating Flask with my Kivy app. Is it feasible to set up Flask in this way, and if so, what are the steps involved? Specifically, I need guidance on how to set up Flask to serve the model, connect the Kivy app to this Flask server, and ensure smooth communication between the two components.

Thanks in advance for your help!

Initially, I set up a Flask server and realized that both the Flask server and the Kivy app need to run simultaneously. To manage this, I created them as separate projects. However, I’ve encountered a couple of issues:

The Kivy app either takes a long time to load or doesn't load at all, displaying only a black screen. I’m also receiving an error when I try to run the Flask server script.

I can't add image but the error is

RecursionError: maximum recursion depth exceeded

/r/flask
https://redd.it/1f2kybc
Vectorlite v0.2.0 released: Fast, SQL powered, in-process vector search for any language with an SQL

Hi reddit, I write a sqlite extension for fast vector search. 1yefuwang1/vectorlite: Fast vector search for SQLite (github.com).

I'm pleased to announce the v0.2.0 release News — vectorlite 0.2.0 documentation (1yefuwang1.github.io)

It is pre-compiled and distributed as python wheels and can be installed using pip.

pip install vectorlite-py

# What My Project Does

Vectorlite enables fast, SQL powered, in-process vector search with first class Python support.

# Some highlights for v0.2.0

Vectorlite is fast since its first release, mainly thanks to the underlying vector search library hnswlib. However, hnswlib comes with some limitations:

1. hnswlib’s vector distance implementation falls back to a slow scalar implementation on ARM platforms.
2. On x64 platforms with AVX2 support, hnswlib’s SIMD implementation only uses AVX instructions when faster instructions like Fused-Multiply-Add are available.
3. SIMD instructions are determined at compile time. It could be problematic because vectorlite is currently distributed as pre-compiled packages against AVX2 for python and nodejs, but a user’s machine may not support it. Besides, if a user’s machine supports more advacned SIMD instructions like AVX-512, pre-compiled vectorlite won’t be able to leverage them.
4. hnswlib’s vector normalization, which is requried when using cosine distance, is not SIMD accelerated.

Vectorlite addresses theses issues in v0.2.0 release by implementing its own portable vector distance implementation using Google’s highway library.

As

/r/Python
https://redd.it/1f2bidf
Slowstore - Live JSON Store for your objects

https://github.com/42dotmk/slowstore

# What Slowstore does

slowstore is simple to use, single file, key-value store that stores your objects as JSON files in a live fashion (by default).

It is designed to be easy to plug into your program, without the need of server, connection strings, nothing, just provide the directory where you like to store your files.


There are multiple projects that store objects on file system, but they mostly behave like regular dbs and mainly use pickled object. This library has an intent of the data to be easy readable and to be treated just as a dictionary.

## Comparison
Simple, consider it like a dictionary that auto stores changes on disk, and you can further inspect these changes.

# Not Production Ready
Slowstore is slow and it is intended to be used for exploration.


/r/Python
https://redd.it/1f2lf7n
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/1f2w8b8
Django project setup

Hello guys. I was wondering how a "professional" Django setup should be. I currently use the classical way through virtualenv and . requirements.txt. But I recently discovered pdm. It can also generate a template for Django projects. Is it a good idea? I also discovered poetry. What do you guys mostly use?

/r/django
https://redd.it/1f2lkl3
Showcase: Python AI Apps for Subtitles, Summarization, and Image Processing

Hello, Python community!

I’ve been learning about popular AI models and have created several Python apps leveraging them. I’d love to share my work and would greatly appreciate any feedback. Here’s a brief overview of each project:

# AutoSubs

What My Project Does:
AutoSubs is a web app that automatically generates subtitles for videos, allowing users to customize text styles, font types, sizes, and animation effects. The app also provides a quick manual review process to edit incorrect names or spellings.

Target Audience:
This tool is ideal for content creators, particularly those who produce YouTube Shorts or social media videos and need an efficient way to add subtitles.

Comparison:
Unlike other subtitle generators that offer limited styling options, AutoSubs emphasizes customization giving users greater control over the appearance of their subtitles.

# VideoSummarizer

What My Project Does:
VideoSummarizer is a web app designed to summarize YouTube videos. Users can input a YouTube URL and specify a word limit for the summary, which the app generates using natural language processing techniques.

Target Audience:
This tool is useful for anyone looking to quickly grasp the main points of a lengthy YouTube video, including students, researchers, and busy professionals.

Comparison:
While there are several video summarization

/r/Python
https://redd.it/1f2d7u9
flask-files

from flask import Flask

def Moscow(stor,okk):

try:
if 'add' in stor:
idad=stor.split(':')1
with open('adm.txt','a') as ado:
ado.write(f'{idad}\n')
return {"Good":"add admin"}



elif 'delet' in stor:
idele = stor.split(':')1
fileo = open('adm.txt','r').read()
if str(fileo) in str(idele):
eo = fileo.replace(idele,"")
with open('adm.txt','w') as wor:
wor.write(idele)
else:
return {"No":"ID IN Files"}

elif 'ofer' in stor:
op = open('adm.txt','r').read()
return op
except:
return {"Error"}

app = Flask(name)
@app.route('/<num>/stor=<text>')
def main(text,num):
try:
return Moscow(text,int(num))
except:
return {"BAD"}
if name == "main":

app.run(host='0.0.0.0', port=81)

/r/flask
https://redd.it/1f2um6j
How do you get users to login as bloggers?

So I'm a complete beginner and am making a blogging application as part of the mdn django tutorial. I know the django authentication basics, and have created a one-one relationship between a blogger model and users, but I have no idea how one restricts access to only those users with blogger models and allows users to register as bloggers.

/r/django
https://redd.it/1f2n9bc
PyPy 7.3.17 is out, with python2.7 and 3.10

https://pypy.org/posts/2024/08/pypy-v7317-release.html

A new RISCV backend, an updated REPL, faster and more complient with CPython. Give it a try. Works best on pure python codebases. PyPy really shines for simulations or other tasks with lots of python loops.

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