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
Naruto Hands Seals Detection (Python project)

I recently used Python to train an AI model to recognize Naruto Hands Seals. The code and model run on your computer and each time you do a hand seal in front of the webcam, it predicts what kind of seal you did and draw the result on the screen. If you want to see a detailed explanation and step-by-step tutorial on how I develop this project, you can watch it here.

/r/Python
https://redd.it/1dng3t3
D which universities and research centers are focusing on adversarial machine learning (especially in Germany) ?

Hey people, I'm curious about where core adversarial learning research is going on. Looking at the publications, I do see several papers from various organizations but rarely do I see an organization advertise that they are focusing on adversarial learning as a field. Especially so for the universities and institutes in Germany.

/r/MachineLearning
https://redd.it/1dnctew
Threading/concurrency and flask

I am trying to make a flask app that does some processing with an LLM in the background. My naive approach was to check the database every second for unprocessed entries and then process them one by one. I did this using Python's threading library. It seems this doesn't actually work when using a real server like gunicorn.

From what I have seen the proper way to do this is using Celery. Celery though seems to work using RabbitMQ, which I have no idea about. The examples seem to be built around redis, wheras my site is built around SQLAlchemy (currently with SQLite for testing but this could change). I don't really get why work queues are necessary. Is there a better way of doing this or do I need to bite the bullet and learn celery?

/r/flask
https://redd.it/1dnn2i5
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/1dnsczh
tell me how I can implement the described feature In my code

I have a drop down menu with iPhones that are an option for repair. for value= or the back end so to say I figured I should include the price , how do I Make it so they get charged that amount at checkout. should I use stripe ?

/r/flask
https://redd.it/1dms9c4
Django website template to speed up your development

Hi everyone!

I saw couple of posts about how tedious and time consuming its to get django website from scratch, especially from freelancers.

So to make things easier I put together a base template, so you can build on that, you can check it out here: [https://github.com/PaulleDemon/Django-website-template](https://github.com/PaulleDemon/Django-website-template)

You can also check out the [Django template demo](https://django-website-template.vercel.app/).

**Some of the features of Django template include**

* **Production ready**: Comes with configurations for production, you can start deploying immediately to Render.com, vercel.com, railway.app etc.
* **Responsive UI**: Comes with a responsive base template, so you can focus on other parts of your websites.
* **Landing page**: Comes with a landing page you can modify.
* **Contact us page**: An inquiry form, to allow your users to contact.
* **Blog with Trix Editor:** An integrated Trix editor on admin panel to manage and write blogs.
* **Custom User model**: Comes with an existing custom user model you can modify.
* **Tailwind Css:** For rapid prototyping and development

You can check out all the feature [here](https://github.com/PaulleDemon/Django-website-template?tab=readme-ov-file#what-features-does-django-template-include).


**Couple of technical details:**

* It comes with Function based views.
* Uses tailwind CSS
* Supports Sqlite / Postgres Database
* You can check the readme.md, to know how to get started and deploy it to production.


**Who is

/r/django
https://redd.it/1dnhlf5
Automating telemetry capture using Python bytecode

This article covers my journey attempting to capture telemetry automatically using Python code. It ended up being super complex and too much for our company to maintain. I'm sharing it to get some insights to see if folks have done anything similar and have ideas!

https://jaywhy13.hashnode.dev/automated-telemetry-capture-via-python-bytecode-modification

/r/Python
https://redd.it/1dnu0po
SciPy 1.14 released

SciPy just released version 1.14: https://github.com/scipy/scipy/releases/tag/v1.14.0

### SciPy 1.14.0 Release Notes

SciPy 1.14.0 is the culmination of 3 months of hard work. It contains
many new features, numerous bug-fixes, improved test coverage and better
documentation. There have been a number of deprecations and API changes
in this release, which are documented below. All users are encouraged to
upgrade to this release, as there are a large number of bug-fixes and
optimizations. Before upgrading, we recommend that users check that
their own code does not use deprecated SciPy functionality (to do so,
run your code with python -Wd and check for DeprecationWarning s).
Our development attention will now shift to bug-fix releases on the
1.14.x branch, and on adding new features on the main branch.

This release requires Python 3.10+ and NumPy 1.23.5 or greater.

For running on PyPy, PyPy3 6.0+ is required.

### Highlights of this release

- SciPy now supports the new Accelerate library introduced in macOS 13.3, and
has wheels built against Accelerate for macOS >=14 resulting in significant
performance improvements for many linear algebra operations.
- A new method, cobyqa, has been added to scipy.optimize.minimize - this
is an interface for COBYQA (Constrained Optimization BY Quadratic
Approximations), a derivative-free optimization solver, designed to
supersede COBYLA, developed by the Department of Applied Mathematics, The
Hong Kong Polytechnic University.
- scipy.sparse.linalg.spsolve_triangular is

/r/Python
https://redd.it/1dnzpx5
What is the best way to catch errors in settings or other places before they crash Gunicorn?

what is the best way to catch errors in settings or other places before they crash Gunicorn?

for example I'm trying to use envparse for getting .env settings, but Django throws an exception and it doesn't get logged.

is there a way to display detailed debug errors like Symfony does in debug mode?

It's been really frustrating coming from the PHP web dev side - setup and debugging is much harder...
But Python is better for the project I'm working on.

Any suggestions for unversal exception catching so I don't have Gunicorn crashing issues with no log output?

/r/django
https://redd.it/1do3dkx
scamming the scammers with python

Source code: https://github.com/IdanHajbeko/revenge\_on\_scammers/

What my Project Does

This Python script sends numerous requests to scam websites using fake but valid credit card information. Each request incurs a small fee for the scammer's payment processor, making their scams costly. Additionally, it floods their login pages with fake usernames and passwords, making it harder for them to sift through and find real credentials.

Target Audience
This script is intended for people who have basic knowledge of Python(or advanced) and want to take down phishing scams.

/r/Python
https://redd.it/1do3dd2
Help with Flask project

Hi, I'm a student currently who has a flask assignment to build a API webserver. I've missed out on a few lessons (I've been sick) and now I'm lost af. I don't know what I'm doing and im stressed out.

Is anyone free to link up on discord? And walk me through a few things?

/r/flask
https://redd.it/1do34jg
R I finetuned GPT-2 and BERT 135,000 times to see if it's fair to pretrain on unlabeled text from the test set

TL;DR: seems fair.

Everyone knows that training on labeled test data is a big no-no if you wanna use that data for evaluation.

But if you pretrain on unlabeled test data, can you still use that data during evaluation?

Let's run an experiment on 25 text classification datasets, two LMs whose pretraining data we're pretty sure are not already contaminated, and across a few settings for the number of training and test observations.

For each dataset, the experiment sanity checks that pretraining on unlabeled text (independent of the test set) helps, i.e., that there's an effect to detect. Call this the pretraining boost. Next, the experiment evaluates the bias from pretraining on unlabeled text from the test set instead of unlabeled independent text. Call this the evaluation bias.

# Results

​

m=50 is based on the Real-world Annotated Few-shot Tasks \(RAFT\) benchmark \(https:\/\/arxiv.org\/abs\/2109.14076\), which also contains the inspiration for this question: “For each task, we release a public training set with 50 examples and a larger unlabeled test set. We encourage unsupervised pre-training on the unlabelled examples…”. The distributions above are those of marginal effects: averaged across 2 LM types, the 25 classification tasks, and their subsamples.

Stretching the intention of “few” in few-shot here. I wanted to

/r/MachineLearning
[https://redd.it/1do2g03
What’s so bad about hosting static HTML with Django?

I've seen people online citing security concerns, how exactly is it insecure vs a NGINX server?


Let me explain my position further:

I usually just spin up a Dockerized Django + Django Ninja API and consume the API with a separate, Dockerized React/Vue static frontend. Now that's two Docker containers in the limited space of my RPi's SD card.

I then discovered that, through some url patterns and some custom template view, I could just export the React/Vue as static HTML as usual, point Django to that path and have Django serve the "index.html" at Django's "/". Now I only need to deploy one Docker container, and I don't need two repos for one app. What's the catch here?

/r/django
https://redd.it/1do4ce2
Form Validation where a user can upload a file or paste its contents.

I've got a a form that I want to allow the user to either upload a json file, or paste the json in a textarea field. Generating the form works fine. However I'm a little stumped about how to validate the data.

How is validation performed against a file upload form field?



/r/django
https://redd.it/1dobcc5
My simple tech stack for building apps (in 2024)

After meeting u/neogener today, I realised that some people might find it helpful to understand what a simple, robust, production tech stack looks like - particularly for a team of 1-5 people.

So here's my simple tech stack for building software in 2024 🎨

(Hand drawn by me 🙂)

* = things I don't use at the start. Most of these asterisked tools are optimisations, which I only need in certain situations.

As an example app, my product (https://photondesigner.com) uses this stack.

TLDR: you don't need many of the technologies that people say you need.

https://preview.redd.it/0ehduf3tcr8d1.jpg?width=2667&format=pjpg&auto=webp&s=d4a100f35dd9e14da424666ebd52e051d209aabe




/r/django
https://redd.it/1doccjh
How to start and stop script from django admin panel

I am continuously scrapping some website so for that website i am making bunch of accounts. I am storing these info into below model

class BotAccount(AppBaseModel):
username = models.CharField(maxlength=20)
password = models.CharField(max
length=100)
deviceid = models.CharField(maxlength=100)
active = models.BooleanField(default=False)

if active is true then that particular bot will automatically login and start scrapping into websites (scrapping script is ready). Its a while condition that goes on forever until BotAccount.objects.first().acive == False

So from admin panel if i uncheck this bot automatically stops. and if checked then bot start working

How do i do this in Django so that whole thing will run in background

/r/django
https://redd.it/1dodz91
N ESM3: Simulating 500 million years of evolution with a language model

Blog post: https://www.evolutionaryscale.ai/blog/esm3-release

Pre-print (pending approval): https://evolutionaryscale-public.s3.us-east-2.amazonaws.com/research/esm3.pdf

Abstract:

> More than three billion years of evolution have
produced an image of biology encoded into the
space of natural proteins. Here we show that language models trained on tokens generated by evolution can act as evolutionary simulators to generate functional proteins that are far away from
known proteins. We present ESM3, a frontier
multimodal generative language model that reasons over the sequence, structure, and function
of proteins. ESM3 can follow complex prompts
combining its modalities and is highly responsive
to biological alignment. We have prompted ESM3
to generate fluorescent proteins with a chain of
thought. Among the generations that we synthesized, we found a bright fluorescent protein at far
distance (58% identity) from known fluorescent
proteins. Similarly distant natural fluorescent proteins are separated by over five hundred million
years of evolution

The first huge release by EvolutionaryScale after spinning off Meta.

Weights and code are released, but with big caveats

From HuggingFace:

https://www.evolutionaryscale.ai/legal/community-license-agreement

The Big Picture:

The EvolutionaryScale AI Model is only available under this Community License Agreement for non-commercial use by individuals or non-commercial organizations.
You may not use the EvolutionaryScale AI Model or any derivative works of the EvolutionaryScale AI Model or its outputs:

a. in connection with any commercial activities, for example

b. to develop any product or service such

/r/MachineLearning
https://redd.it/1do91g9
GeoPandas 1.0 released!

A good 10 years after it's first 0.1 release, GeoPandas just tagged their 1.0 release!

Release page: [https://github.com/geopandas/geopandas/releases/tag/v1.0.0](https://github.com/geopandas/geopandas/releases/tag/v1.0.0)
Changelog: https://geopandas.org/en/latest/docs/changelog.html
1.0 tracking issue: [https://github.com/geopandas/geopandas/issues/3201](https://github.com/geopandas/geopandas/issues/3201)
1.0 milestone: https://github.com/geopandas/geopandas/milestone/4?closed=1

About GeoPandas

>GeoPandas is an open source project to make working with geospatial data in python easier. GeoPandas extends the datatypes used by pandas to allow spatial operations on geometric types. Geometric operations are performed by shapely. Geopandas further depends on pyogrio for file access and matplotlib for plotting.

/r/Python
https://redd.it/1do71es
Modern Notepad using PyQt6 UPDATE | ZenNotes

# What does my Project do?

ZenNotes is a minimalistic Notepad app with a sleek design inspired by Fluent Design. It offers the familiar look of the Windows Notepad while having much more powerful features like Translate, TTS, etc.

Text to Speech
Markdown support
Translation
Get Wikipedia Articles

And much more.

# Target Audience

People who want a better but similar experience and look as that of Windows Notepad

# Comparison

Unlike Windows Notepad, it has support for Markdown, TTS, etc

Moreover, it has a great UI.

# Update

This is an update post to this

# GitHub

GitHub Link: https://github.com/rohankishore/ZenNotes

/r/Python
https://redd.it/1do46ez
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/1doks2x