pythondaily | Education

Telegram-канал pythondaily - Python Daily

1102

Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels

Subscribe to a channel

Python Daily

Ticked 0.2.1 Major Release- A terminal based productivity hub built over Textual

My favorite part of this update revolves around the integration of Canvas LMS. Allowing students to interact with their University courses through the terminal has been a huge goal of mine with this project and I'm happy to say this is only the beginning of my plans for it.

I have also allowed for any Spotify Premium user to interact with the API by inputting their own Client ID and Secret into the app and updated my built-in code editor NEST+ to support some simple quality of life editing features like tab buffers, auto-indentation and auto-pairs.

You can read the full release here, or read the documentation for the app here for more details on the usage of these features. Thank you to everyone who's helped on the project thus far!

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

Читать полностью…

Python Daily

I Built a Tool Automatically Detect and Censor Human Faces in Images and Videos with YOLO

Hi everyone! I wanted to share a project I've been working on - an automated system for detecting and censoring faces in images and videos using YOLOv8 and Python.

~~I currently only have Gaussian Blur as a masking method, but I plan on adding a few more methods.~~

Edit: I have now implemented: Gaussian Blur, Emoji, and Text masking (demonstration images in GitHub repository).

GitHub Repository: [https://github.com/Spring-0/face-censor](https://github.com/Spring-0/face-censor)

# What My Project Does

Main Features:

* Automatically detects faces in images and videos using YOLOv8.
* Applies blur censoring to the detected faces and saves a new image/video.
* Built with extensibility / modularity in mind.
* I have also included a already trained model in the repository in-case someone wants to use it out the box without having to worry about training it themselves. (I have also included the code to train it)

# Target Audience

This project is aimed at:

* Video editors that previously had to manually censor out faces.
* Developers who want to integrate this in their projects.
* Anyone that would be interested in censoring human faces in images/videos.

# Comparison

I have looked into a few projects that had the same idea, except I could not find any that were easy to implement. And this was built using YOLO, making

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

Читать полностью…

Python Daily

Saturday Daily Thread: Resource Request and Sharing! Daily Thread

# Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

## How it Works:

1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.

## Guidelines:

Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.

## Example Shares:

1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.

## Example Requests:

1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟

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

Читать полностью…

Python Daily

I made a weekly fantasy golf app in Flask

Golf Pool is a simple app for users to pick a "fantasy team" of players in the weekly PGA events, and get live scoring compared to other users' teams. Golfers in each event (the 'field') are grouped into 5 tiers according to their initial rank and win odds. Users pick 1 player from the top tier, 2 from the 2nd tier, 3 from 3td etc, for a total of 15, with their 5 best player scores counted as their team score.

https://app.weeklygolfpool.com/

The American Express Championship is underway, so have a look but you won't be able save a team now. Come back next Wednesday to pick a team for the Farmers Insurance Open in San Diego, or the week following for the AT&T Pebble Beach Pro-Am, sometimes referred to as the unofficial start of golf season.

In the near future you will be able to create your own league to compete with friends, instead of all in one big league as it is now. Please let me know if you have other suggestions or questions. Fore!

EDIT: Not sure why my screen images aren't included in post

/r/flask
https://redd.it/1i3pkly

Читать полностью…

Python Daily

It Shouldn't Be This Much Work to Sync Data Between Django and Vue SPA

I love Django, I love Vue SPAs - but I don't like spending time writing boilerplate code to link the frontend to backend models. Serializers, Views, Services, State Management, Caching, yeah... it's a lot. So I built a system that gives Vue SPAs reactive, real-time sync with Django models. No boilerplate - just write Django models and get a reactive frontend data layer where every component's view is automatically, instantly synced with the actual database state, whether changes come from other clients, background tasks, admin panels, or anywhere else. It's snappy enough to power real-time applications like chat apps and leverages Django Rest Framework under the hood.

Demo - two clients both connected to the remote backend, staying in sync

https://i.redd.it/p89ph27enkde1.gif

Out of the box, you get smart caching that invalidates correctly when CRUD operations occur (on another client, or a Django backend initiated save), optimistic UI updates, and sophisticated backend performance optimizations. Request serializer caching, automatic model schemas, and real-time synchronization come for free - without writing any additional plumbing code. The system intelligently manages data consistency, providing a seamless, responsive experience across client and server. This approach should also work for React apps - but I've not looked into this yet.

Minimal

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

Читать полностью…

Python Daily

Showcase: Python-Lotion – A Lightweight Wrapper for the notion-client (Beta)

Hi everyone,



I’d like to share my new project: Python-Lotion, a lightweight Python wrapper for the notion-client. 🚀



What My Project Does



Python-Lotion is designed to make working with the Notion API simpler and more intuitive. It wraps around the popular notion-client library, providing a cleaner interface for fetching, creating, and managing Notion pages and blocks. This is especially useful for developers looking to integrate Notion into their Python projects with minimal effort.



Target Audience



This project is aimed at:

• Developers working on production applications requiring Notion API integrations.

• Enthusiasts exploring Notion automation for personal use.

• Anyone looking for a lightweight and straightforward alternative to existing Notion API libraries.



Comparison



Here’s how Python-Lotion differs from existing alternatives like notion-client:

• Simpler syntax: Python-Lotion focuses on reducing boilerplate code for common tasks.

• Lightweight design: Aims to stay small and focused, avoiding unnecessary complexity.

• Work in progress: Currently in beta, with plans to expand features and improve usability over time.



What’s Next

• Expanding the documentation to make onboarding easier.

• Adding advanced block management functionality, such as creating, updating, and organizing blocks within pages.



The source code is open on GitHub: https://github.com/koboriakira/python-lotion.

Feedback, suggestions, and ideas for improvement are highly welcome!



Thanks for checking it out! 🙌

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

Читать полностью…

Python Daily

Grokking at the Edge of Numerical Stability Research

>Grokking, the sudden generalization that occurs after prolonged overfitting, is a surprising phenomenon challenging our understanding of deep learning. Although significant progress has been made in understanding grokking, the reasons behind the delayed generalization and its dependence on regularization remain unclear. In this work, we argue that without regularization, grokking tasks push models to the edge of numerical stability, introducing floating point errors in the Softmax function, which we refer to as Softmax Collapse (SC). We demonstrate that SC prevents grokking and that mitigating SC enables grokking without regularization. Investigating the root cause of SC, we find that beyond the point of overfitting, the gradients strongly align with what we call the naïve loss minimization (NLM) direction. This component of the gradient does not alter the model's predictions but decreases the loss by scaling the logits, typically by scaling the weights along their current direction. We show that this scaling of the logits explains the delay in generalization characteristic of grokking and eventually leads to SC, halting further learning. To validate our hypotheses, we introduce two key contributions that address the challenges in grokking tasks: StableMax, a new activation function that prevents SC and enables grokking without regularization, and ⊥Grad,

/r/MachineLearning
https://redd.it/1i34keg

Читать полностью…

Python Daily

flask and underscores in headers

I am writing a server that handles request from a client app that I do not have any control over. The app sends a specific header "access_token" which my server needs to receive. Unfortunately, by default, Flask seems to throw these values away. I can see the header traveling over the network in my Wireshark output, but when it arrives at my server Flask is completely blind to it. Since I can't control the client app the general solution of "just don't use underscores" isn't going to work for me. Anyone have a solution that allows Flask to receive and process headers with underscores in them?

/r/flask
https://redd.it/1i2h8po

Читать полностью…

Python Daily

How do I Make Calender

I want to make a calender app. Should I use fullcallenderio? I've tried to make it myself but I have limited knowledge on JS

/r/flask
https://redd.it/1i2qpa8

Читать полностью…

Python Daily

Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

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

Читать полностью…

Python Daily

Show Django forms inside a modal using HTMX
https://joshkaramuth.com/blog/django-htmx-modal-forms/

/r/djangolearning
https://redd.it/1i18ruq

Читать полностью…

Python Daily

Building a Machine Learning Model from Scratch in Python

Model Architecture, Evaluation, Data Prep, and more covered in a tutorial: https://codedoodles.substack.com/p/build-your-own-machine-learning-model



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

Читать полностью…

Python Daily

I wrote optimizers for TensorFlow and Keras

What My Project Does:

This library implements optimizers for TensorFlow and Keras that are used in the same way as Keras optimizers. This library contains optimizers that Keras doesn't include. You can use these optimizers on models built with TensorFlow or Keras.

Target Audience:

This library is helpful for anyone using TensorFlow and Keras.

Comparison:

This library implements optimizers not included in Keras.


https://github.com/NoteDance/optimizers

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

Читать полностью…

Python Daily

Flask in AWS Lambda not showing favicon

I have an AWS lambda built using Flask, served through API Gateway. This is deployed to AWS using Terraform. I am unable to get the favicon to load correctly when deployed through this method. The favicon works flawlessly on my local machine.

Following the advice discovered here, I am able to get the icon URL to no longer return a 502; it returns a 200. However, the icon is unable to be displayed. I can navigate directly to the icon in the browser, but I still have the same undisplayed image.



I have tried using a PNG instead of ICO, with the same results.

Of note, when I am able to see the icon locally, I see it loads with type image/x-icon, but remotely it loads as image/vnd.microsoft.icon.

My handler setup:

def handler(event, context):
base64contenttypes = "image/vnd.microsoft.icon", "image/x-icon"
return awsgi.response(app, event, context, base64contenttypes)


HTML link <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">

favicon.ico is stored in the /static directory.

API specs in Terraform

resource "awsapigatewayrestapi" "api" {
body = jsonencode({
"openapi" : "3.0.1",


/r/flask
https://redd.it/1i2shcl

Читать полностью…

Python Daily

Is it a good practice to wrap immutable values in list's or other mutable types to make them mutable

so the question is really simple is it this good practice

def modx(x):
x[0] += 1

val = [42]
mod
x(val)

is this ok to do I dont have a spesific use case for this except maybe implementing a some data structures. I am just wondering if this is a good/bad practice GENERALLY

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

Читать полностью…

Python Daily

🎬 Django Webflix - Subscription-Based Movie Streaming Platform

Hey everyone! I wanted to share my Django project that might help other beginners. It's a subscription based streaming(though streaming isn't available yet) platform that I built to learn Django and Stripe(dj-stripe) integration.

https://preview.redd.it/enj12z69ksde1.png?width=1212&amp;format=png&amp;auto=webp&amp;s=578bd921e3f7a926ac3a80387e3a28f55b2c34c0

Key Features:

User authentication
Movie/TV series browsing
Watch-lists & Favorites
Review system
Stripe subscription system
Responsive design



What You'll Learn:

Django models & relationships
Class-based views
Template inheritance
Stripe integration
User authentication



Tech Stack:

Django 5+
Python 3.11+
Bootstrap 4
SQLite/PostgreSQL
Stripe



Perfect for beginners who want to:

1. Practice Django fundamentals
2. Learn Stripe integration
3. Understand user authentication
4. Work with AJAX requests
5. Handle file uploads
6. Implement search functionality



The code is well-commented and follows Django best practices. I've included sample data generators to help you get started quickly.

Github Repo

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

Читать полностью…

Python Daily

how can i make a form created in admin accessible to all user

i created several mock data inside the admin page of django. these data are book forms (book title, summary, isbn).

im trying to fetch these data and put it on my ui (frontend: reactjs) as well as make sure these mock data are saved in my database (mysql) but everytime i try to access it django tells me i dont have the authorisation. i double checked and configured my jwt token and made sure to [isAuthenticated\] my views but i still keep getting 401

error: 401 Unauthorized

anyone know how to get around this?

/r/djangolearning
https://redd.it/1i3z34k

Читать полностью…

Python Daily

Building app with Flask, a blueprint for APIs and celery for tasks queuing

Hello,

I'm building a web app that should automate some tasks to run towards network devices.

For my backend, I'm using Flask and I managed to integrate celery in the code.

Now, I needed to update the project structure so I decided to create an entry point and an "api" folder that will contain all the different APIs different each network device.

I can run celery with no issues with the new structure but I'm having problems with accessing the routes on flask. The code is here https://github.com/californinson/AutoTestingPub/tree/main

I'm using run.py as the entry point. tasks.py creates the flask and celery apps using the two functions created on config.py. api/f5/f5_api.py should contain all the flask routes I will need. I also configured the blueprint inside.

I can compile and run run.py but when any API is called I see this error on the logs:

"POST /api/f5/list_files HTTP/1.1" 404 -

"POST /api/f5/user_login HTTP/1.1" 404 -

I went through documentations and articles but I can't understand why flask somehow can't reach the routes in f5_api.py.

The routes are being called with URL "http://local_ip:5000/api/f5/list_files" and "http://local_ip:5000/api/f5/user_login"

I would definitely need a look from someone "external".

What am I doing wrong?

/r/flask
https://redd.it/1i3k23v

Читать полностью…

Python Daily

Best practices mocking in Django Rest Framework

From my studying I learned that to have tests that are not brittle you should use as little mocking as possible.

In my API endpoints, I have secured it with the Django OAuthlib that requires the requests to have Authorization header with a token in it. If I want to test the endpoint functionality only and thus mock the call to the library to always allow the request whatever the token value is, is that a brittle test? Since if I change my authentication method, all my mocks will have to be updated? What is the general best practice for mocking with Django DRF?

/r/djangolearning
https://redd.it/1i3i9yz

Читать полностью…

Python Daily

AnonChat - Anonymous chat application

**What My Project Does**

A simple and anonymous chat application written in Python3 using sockets.

**Target Audience**

Just my first project to test my skills.

target: everybody who just want to test.

**Comparison**

* Simple
* lightweight design using tkinter
* Secure

The source code in open on Github [https://github.com/m3t4wdd/AnonChat](https://github.com/m3t4wdd/AnonChat)

Feedback, suggestions, and ideas for improvement are highly welcome!

Thanks for checking it out! 🙌

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

Читать полностью…

Python Daily

I made a simple python scripts that automate deletion of your ChatGPT chats

Hey! I was considering whether to post this or not, and I decided other people may have had this issue too, where you been using chatGPT all the time, there's like a thousand chats, I was in this predicament and made a program that I made on Linux for firefox with Selenium, that essentially automatically goes through and starts deleting your chats on chatGPT.

I made it on Linux, I have no clue the compatibility with windows, and it's for firefox, If anyone else who's in this predicament wants to use it feel free!
Github:

https://github.com/TheBlewish/Automated-ChatGPT-Chats-Deletion

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

Читать полностью…

Python Daily

Function use counters in Visual Studio Code

Many language extensions in VSCode include features that show the number of references to a specific function, class, or entity.


We've just released an extension that brings this functionality to Python, displaying reference counters for top-level functions and classes. Clicking a counter reveals a list of references.


Try it out here Tooltitude for Python


P.S. This is a newly released extension, and we’d love your feedback!


P.P.S. It’s not our first VSCode extension. Check out Tooltitude for Go, which has been on the marketplace for ~2 years, offering similar functionality for Go and more, with plenty of positive reviews.







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

Читать полностью…

Python Daily

For those of you who user raspberry pi scripts and eink screen, what driver do you use?

It is for waveshare 7.3 inch color. I looked in their documentation and added this python code

from waveshare_epd import epd7in3g,
epd = epd7in3g.EPD()



This might be stretching what is allowed to post here, but I thought I would ask. Does that look correct. I previously had a python script working correctly with a black and white screen.

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

Читать полностью…

Python Daily

Prevent accidentally running python scripts with missing or incorrect shebang

I do this too often so I realized I could nip it with a chmod wrapper:

#!/bin/bash
# Prevent accidentally running python scripts with missing or incorrect shebang
if [ "$1" == "+x" && "$2" =~ \.py$ ]; then
firstline=$(head -n 1 "$2")
if [[ "$first
line" != "#!"python ]]; then
echo "Error: Python file detected with invalid shebang"
exit 1
fi
fi
/usr/bin/chmod "$@"

Since it's always 1. write myscript.py, 2. chmod +x myscripy.py, 3. ./myscript.py, 4. oops.

Does anyone else make this mistake? Sometimes I even write !/bin/bash...
Some lines end up being valid bash, e.g import statements via /usr/bin/import from imagemagick, and have seen random files generated (hopefully nothing destructive!).

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

Читать полностью…

Python Daily

Feedback on my first Flask site

https://redd.it/1i2n7xw
@pythondaily

Читать полностью…

Python Daily

Best practices for Flask and DynamoDB?

I've built a few side projects with Flask and DynamoDB and, while it's not a complicated feat, I feel like things are always a bit more cumbersome than they should be. Perhaps it's by Django background, but I think there has to be a better way to do what I'm doing. Does anyone have a favorite resource (tutorial, course, book) to learn best practices for Flask+DynamoDB?

/r/flask
https://redd.it/1i2x4i2

Читать полностью…

Python Daily

My first django project

Hi, I am a college 2nd year trying to get more experience and I learned Django for around 3ish months. With learning, I made this simple project and I wanted to get feedback on where I can improve and if this is good enough to put on my resume. The only thing I'm worried about is if these projects are overdone and putting on my resume is worth it. Thank you! This is the Github: https://github.com/Ryan11c/mathify the live version is also linked inside the repo!



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

Читать полностью…

Python Daily

fruitstand: A Library for Regression Testing LLMs

I have recently been finished the first version of a library I've been working on called fruitstand



What My Project Does

fruitstand is a Python library designed to regression test large language models (LLMs). Unlike traditional deterministic functions, LLMs are inherently nondeterministic, making it challenging to verify that a model upgrade or switch maintains the desired behavior.

fruitstand addresses this by allowing developers to:

• Create a Baseline: Capture responses from a current LLM for specific test queries.

• Test New Models: Compare responses from other models or updated versions against the baseline.

• Set a Similarity Threshold: Ensure that new responses are sufficiently similar to the baseline, thereby maintaining consistent application behavior.

This is particularly useful for tasks like intent detection in chatbots or other applications where maintaining a consistent response is critical during model updates.



Target Audience

fruitstand is primarily aimed at developers and data scientists working with LLMs in production environments. It is useful for:

• Ensuring Consistency: For applications where consistent behavior across LLM versions is critical, like chatbots or automated customer support.

• Regression Testing: Those who want to automate the process of verifying that new model versions do not degrade the performance of their systems.

• LLM Comparison: Anyone looking to switch between different LLM providers

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

Читать полностью…

Python Daily

Django 5.2 alpha 1 released
https://www.djangoproject.com/weblog/2025/jan/16/django-52-alpha-1-released/

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

Читать полностью…

Python Daily

DeepEval: The Open-Source LLM Evaluation Framework

Hello everyone, I've been working on DeepEval over the past \~1 year and managed to somehow grow it to almost half a million monthly downloads now. I thought it would be nice to share what it does and how may it help.

What My Project Does

DeepEval is an open source LLM evaluation framework that started off as "Pytest for LLMs". This resonated surprisingly well with the python community and those on hackernews, which really motivated me to keep working on it since. DeepEval offers a ton of evaluation metrics powered by LLMs (yes a bit weird I know, but trust me on this one), as well as a whole ecosystem to generate evaluation datasets to help you get up and running with LLM testing even if you have no testset to start with.

In a nutshell, it has:

(Mostly) Research backed, SOTA metrics covering chatbots, agents, and RAG.
Dataset generation, very useful for those with no evaluation dataset and don't have time to prepare one.
Tightly integrated with Pytest. Lots of big companies turns out are including DeepEval in their CI/Cd pipelines
Free platform to store datasets, evaluation results, catch regressions, etc.

Who is this for?

DeepEval is for anyone building LLM applications, or

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

Читать полностью…
Subscribe to a channel