pythondaily | Образование

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

Подписаться на канал

Python Daily

D Self-Promotion Thread

Please post your personal projects, startups, product placements, collaboration needs, blogs etc.

Please mention the payment and pricing requirements for products and services.

Please do not post link shorteners, link aggregator websites , or auto-subscribe links.

--

Any abuse of trust will lead to bans.

Encourage others who create new posts for questions to post here instead!

Thread will stay alive until next one so keep posting after the date in the title.

--

Meta: This is an experiment. If the community doesnt like this, we will cancel it. This is to encourage those in the community to promote their work by not spamming the main threads.

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

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

Python Daily

Have any of you looked at NiceGUI as a front-end for django?
https://nicegui.io

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

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

Python Daily

I made a python program that gives LLMs running locally the power to search the internet for LLMs ru

Hey Reddit!

I'm excited to share a project I've been pouring countless hours into: Web-LLM Assistant. It's a Python program that gives local LLMs running via llama.cpp the power to search the internet and provide up-to-date answers.

Here's how it works:

1. You ask a question to the LLM.
2. The LLM crafts a search query and selects a timeframe.
3. It performs a web search, collecting the top 10 results.
4. The LLM picks the 2 most relevant results and fully web scrapes them.
5. If the information is sufficient, it answers your question.
6. If not, it refines the search up to 5 times to find the best answer.

This means your local LLM can now tackle questions about recent events or topics outside its training data!

Key Features:

* Real-time web searching
* Intelligent result selection
* Full web scraping of chosen results
* Iterative search refinement
* Works with your local LLM setup

I'd love for you to check it out and give it a spin! You can find the project on GitHub:

https://github.com/TheBlewish/Web-LLM-Assistant-Llama-cpp

Let me know what you think, and feel free to ask any questions. Your feedback is greatly appreciated!



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

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

Python Daily

Enhance Your Django Project with dj-logging: A Powerful and Easy-to-Use Logging Solution

Today, I’m excited to share a new Django package I’ve been working on called dj-logging! dj-logging is a logging solution tailored specifically for Django projects.

It’s designed to be easy to set up while offering powerful features to help you keep track of what’s happening in your application.
Let me walk you through some of its key features: Effortless Setup: You can get started with logging in just a few steps, with sensible defaults right out of the box.
Level-Based Logging: Automatically logs each level (INFO, WARNING, ERROR, etc.) into its own file, making it easy to track down specific types of messages.
Colorized Console Output: Logs are color-coded in the console, so you can quickly spot different log levels at a glance.
Email Notifications: Critical errors or issues? No worries—dj-logging can send email notifications for ERROR and CRITICAL logs, keeping you informed in real-time.
Request Middleware: The package includes a middleware that logs essential request details like the request path, user info, IP address, and browser type—perfect for debugging and monitoring.
Highly Customizable: You can easily tweak log formats and handlers to suit your project’s needs.
Whether you’re looking to improve your logging

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

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

Python Daily

Avoid redundant calculations in VS Code Python Jupyter Notebooks

Hi,

I had a random idea while working in Jupyter Notebooks in VS code, and I want to hear if anyone else has encountered similar problems and is seeking a solution.

Oftentimes, when I work on a data science project in VS Code Jupyter notebooks, I have important variables stored, some of which take some time to compute (it could be only a minute or so, but the time adds up). Occasionally, I, therefore, make the error of rerunning the calculation of the variable without changing anything, but this resets/changes my variable. My solution is, therefore, if you run a redundant calculation in the VS Code Jupyter notebook, an extension will give you a warning like "Do you really want to run this calculation?" ensuring you will never make a redundant calculation again.

What do you guys think? Is it unnecessary, or could it be useful?

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

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

Python Daily

Flask/Werkzeug Password Hash Issue

I've had a production application or 2 years now. It's a bit outdated now, running Flask 2.1.3 and Werzeug 2.0.3 or similar.

I've updated all the code now to support Flask 3.0.0.

It works fine! The issue is now the migration. If I push LIVE the latest build, Werzeug doesn't support SHA256 anymore, you have to use PBKDF2:SHA256 when generating the password hashes.

The issue is my entire database over 30,000 users off the application passwords are hashed using they legacy Werzeug hash. I cannot see ANY way in the docs to convert the legacy hash to the new hash!

So current the Flask 3.0.0 version is working fine but NOBODY can authenticate in the test suite, due to this password hash issue.

Has anybody come across this, how did they migrate?


UPDATE: I managed to go back into the 2.0.3 version REPO of Werkzeug, and copy the hash there, so now if a user logs in it attempts to match the hash, if it errors with "ValueError" due to the hash being unsupported, it then runs the legacy hash code, if it matches that, then it converts it to the new hash method and updates the postgresql database.

Cheers.



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

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

Python Daily

Using Wikipedia views to build an alternative to the deprecated Google Correlate

If you are from the old days of the internet you might remember Google Correlate.

You could draw a line and it would show you similar search patterns. I kind of miss tinkering with it, so I tried to build my own with Python and open data:

* Scrape Wikipedia page views
* Transform data into a pivot table (columns = title, y = views per day)
* Use similarity search to find correlated articles

And finally we can find the closest neighbor in Python with:

from sklearn.neighbors import NearestNeighbors
nn = NearestNeighbors(n_neighbors=25, algorithm='auto',metric='cosine')
nn.fit(data)
distances, indices = nn.kneighbors(query.reshape(1,-1), n_neighbors=50)

Source:

[https://franz101.substack.com/p/google-correlate-alternative-similiarity](https://franz101.substack.com/p/google-correlate-alternative-similiarity)

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

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

Python Daily

Pujo Atlas Developer Call-The Ultimate Pandal Hopping Guide to Durga pujo in Kolkata!

Join the Pujo Atlas Project: Calling Flutter, Django, and Web Developers!

At r/kolkata, we’re building Pujo Atlas—an app that will be a go-to resource for Pujo enthusiasts and pandal hoppers. This app will guide users to notable Durga Puja pandals across the city, helping them explore Kolkata's rich cultural heritage during the festivities.

### Current Challenge

While we’ve made significant progress on the UI/UX front, our frontend and backend development is lagging due to a lack of dedicated developers. We need contributors with expertise in Flutter (frontend) and Django (backend) to help push the project forward.

### What We’re Looking For

Backend (Django, Python):
- Strong knowledge of Django and Python for backend services.

Frontend (Flutter/Dart):
- Experience building cross-platform mobile apps using Flutter.

DevOps (AWS):
- Familiarity with setting up and maintaining services on AWS.

UI/UX:
- Experience working with Figma, Material 3 Design, and optionally Apple Human Interface Guidelines.

Web Development (React & TypeScript):
- Tech stack: React, TypeScript
- Nice-to-have: Familiarity with Git, Astro, Tailwind, and Leaflet
- Level: Beginner in React & TypeScript, but with a solid understanding of JavaScript. Should have experience building mobile-responsive web apps with React.

### Incentives

Pujo Atlas is an FOSS project, so

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

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

Python Daily

Formatron: a high-performance constrained decoding library

# What My Project Does

Formatron allows users to control the output format of language models with minimal overhead. It is lightweight, user-friendly, and seamlessly integrates into existing codebases and frameworks.

# Target audience

Developers who want to make LLM reliably generate structured text(like json)

# Comparison

In summary, Formatron is fast(in fact, fastest in my tiny benchmark) and is a library rather than a framework, so it is more integrable into existing codebases. You can check the details below.

# Features

🔗 Popular Library Integrations: Supports transformers, exllamav2, vllm and RWKV.
🔌 Plugins, not wrappers: Instead of wrapping third-party libraries in large, cumbersome classes, Formatron offers convenient, clean plugins for different libraries.
💡 Library, not framework: Instead of unifying everything into a bulky framework, Formatron is a flexible library that can be embedded anywhere.
✍️ Fluent Formatting: Describe your format as easily as writing natural language.
📜 Regex and CFG Support: Effortlessly interleave regular expressions and context-free grammars (CFG) in formats.
⚙️ Efficient JSON Generation: Feature-complete JSON generation based on Pydantic models or json schemas.
📤 Batched Inference: Freely specify different formats for each sequence in one batch!
🚀 Minimal Runtime Overhead: With Leo optimization, a specialized compacting algorithm, and CFG caches across generations, Earley algorithm

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

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

Python Daily

Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas 💡

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

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

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

Python Daily

i keep getting KeyError: 'Worksheet cpn spread does not exist.'

Hey ! Im trying to build an app ( or practice building an app) and i am taking the info from python over to excel. However, when i add the file path and run the code ikeep getting this

KeyError("Worksheet {0} does not exist.".format(key))

KeyError: 'Worksheet cpn spread does not exist.'

i don't know what im putting in my code wrong.

import openpyxl

from openpyxl import loadworkbook
root=tkinter.Tk()
file
path=r"C:\Users\luna\Documents\cpn spread.xlsx"
A=openpyxl.loadworkbook(filepath)
B=A"cpn spread"

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

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

Python Daily

Data Science Learning Resources

Hi everyone,



I've created a list of resources to learn data science
https://github.com/AI-ML-Notes/Awesome-Data-Science-Resources


I’ll add some more resources like these:
•⁠ ⁠https://www.deeplearning.ai/resources/

•⁠ ⁠https://github.com/afshinea/stanford-cs-221-artificial-intelligence/blob/master/en/super-cheatsheet-artificial-intelligence.pdf
•⁠ ⁠https://github.com/afshinea/stanford-cs-229-machine-learning/blob/master/en/super-cheatsheet-machine-learning.pdf
•⁠ ⁠https://github.com/afshinea/stanford-cs-230-deep-learning/blob/master/en/super-cheatsheet-deep-learning.pdf
•⁠ ⁠https://github.com/shervinea/mit-15-003-data-science-tools/tree/master/en
•⁠ ⁠https://github.com/shervinea/stanford-cme-102-ordinary-differential-equations

•⁠ ⁠Deeplearning.ai Gen AI Short courses


Hope you find it helpful. If you could suggest some more, please reply or create a PR.

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

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

Python Daily

Create new python module named proxyaudit

Hii python enthusiast,

I creates a python library named proxyaudit ., which helps in finding working and free proxies http , https,socks4. ,socks 5 from the free proxy list or any list .

This proxies can help to scrape the web , Building a web crawler , Testing , Launching an DDOS attack and many more . I would love your feedback and stars to my github repo .

https://github.com/aryanyk/proxyaudit

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

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

Python Daily

I created my first ever API using flask

I've been tinkering with Python for a few years as a hobby (I'm in product management, not a developer).

Recently, I decided to create my first API using Flask. I wanted something very simple but fun, so I took inspiration from the classic Chuck Norris joke API that's been around forever.

Here's what I did:

1. GET joke script: I built a Python script to hit the Chuck Norris random joke endpoint, save to SQLite, and check for duplicates as I insert new jokes. The script hits the endpoint every 0.5 seconds, going through dedupe/save logic while ignoring dupes. I let it run overnight and ended up with 9000+ jokes in my DB! TY chucknorris.io!
2. New Chuck Norris API: I chose Flask (since I know it best) along with SQLite DB to build the endpoint. I also created a Chuck Norris-themed documentation page that I had chatGPT spice it up a but with some Chuck Norris inspired humor. Probably a little overboard but it was fun.

You can check out my first API here: http://cnichols1734.pythonanywhere.com

Let me know what you all think! I'm pretty excited about how it turned out, especially given that this is my first real API project. Any feedback or

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

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

Python Daily

Flask App Deployment

Hi, I have finished building a Flask app and have tried numerous deployment services (PythonAnywhere, Vercel, Render, etc.). I've even tried Google Cloud. My app uses AI and is using meta.ai for its AI features. Using meta.ai makes API calls to Meta. When running locally, the app works as expected. However, when deploying, I've received a series of errors that I have been unable to solve. PythonAnywhere did not include meta.ai in its whitelist of sites, and Render and Vercel kept telling me that the requests were timing out, which has never been an issue when testing. I'd appreciate it if anyone could provide any alternatives to the platforms above that would enable me to deploy my app.
Thank you in advance!

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

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

Python Daily

django-nice v0.1.0
https://github.com/rexsum420/django-nice

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

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

Python Daily

GPU acceleration released in Polars

Together with NVIDIA RAPIDS we (the Polars team) have released GPU-acceleration today. Read more about the implementation and what you can expect:

https://pola.rs/posts/gpu-engine-release/

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

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

Python Daily

Best practice regarding serializers in DRF

I have two sets of snippets here. The snippet is related to fetching chat\_rooms and messages associated with each room. My question is which set of snippet is a better practice. Any info will be greatly appreciated. Thank you.

Example 1:

class ChatRoomNameSerializer(serializers.ModelSerializer):
owner = serializers.StringRelatedField()
class Meta:
model = ChatRoomName
fields = ['id', 'owner', 'name', 'created']

class ChatRoomNamesView(ListAPIView):
permission_classes = [AllowAny]
queryset = ChatRoomName.objects\
.prefetch_related('messages').all()

def list(self, request, *args, **kwargs):
serializer = ChatRoomNameSerializer(self.get_queryset(), many=True)
for data in serializer.data:


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

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

Python Daily

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/1fik7f7

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

Python Daily

Tiny BASIC in Python

# What My Project Does

Have you ever wanted to program like your grandparents did in 1976? For my first Python project, I developed Tiny BASIC in Python: [https://github.com/John-Robbins/tbp ](https://github.com/John-Robbins/tbp) (tbp for short). Wanting to dive into programming languages, I needed an easy target language so I could develop all parts of an interpreter.

My target was the [Tiny BASIC](https://en.wikipedia.org/wiki/Tiny_BASIC) language first proposed by Dennis Allison in the first issue of [Dr. Dobb’s Journal of Computer Calisthenics & Orthodontics in January 1976.](https://archive.org/details/dr_dobbs_journal_vol_01/mode/2up) Special thanks to [Dr. Tom Pittman](http://www.ittybittycomputers.com/IttyBitty/TinyBasic/index.htm) for posting much of the documentation of his implementation sold the same year.

Features:

* Full language support, including the USR function.
* A full **DEBUGGER** built in with breakpoints, single stepping, call stack and variable display.
* Loading and saving programs to/from disk.
* A built-in linter for Tiny BASIC code.
* Complete documentation with development notes (over 17,000 words!)
* Full GitHub Actions CI implementation that work with branch protections for code and the documentation web site.
* 290 individual unit tests with 99.88% coverage across macOS, Windows, and Linux.

The [README](https://github.com/John-Robbins/tbp) for tbp has a GIF showing off tbp's functionality, including using the built in debugger to cheat at a game. Not that I advocate cheating, but it made

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

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

Python Daily

feather-test: a multiprocess unit testing framework with event driven reporting

# Introducing Feather Test: An Event-Driven Testing Framework for Python

Hello, I've been working on a new testing framework called Feather Test. It's designed to bring event-driven architecture to Python testing, offering flexibility, parallel execution, and customizable reporting.

## Key Features

- 🚀 Event-driven architecture for flexible test execution and reporting
- ⚡ Parallel test execution for improved performance
- 📊 Customizable reporters for tailored test output
- 🧰 Command-line interface similar to unittest for ease of use
- 🎨 Support for custom events during test execution

## What My Project Does

Feather Test is a Python testing framework that introduces event-driven architecture to the testing process. It allows developers to:

1. Write tests using a familiar unittest-like syntax
2. Execute tests in parallel for improved performance
3. Create custom reporters for tailored test output
4. Extend the test execution environment with custom test servers
5. Utilize custom events during test execution for more flexible testing scenarios

## Quick Example

Here's a simple test case using Feather Test:

from feathertest import EventDrivenTestCase

class MyTest(EventDrivenTestCase):
def test
example(self):
self.assertTrue(True)



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

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

Python Daily

Computational Mathematics Differential Equations Project

https://www.academia.edu/123906379/Computational\_Mathematics\_Differential\_Equations\_Project

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

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

Python Daily

Kahoot on python

Hey I’m doing a kahoot game on python. For the gui I’m suing html page one for client one for sever. Some times when I start the game only one client start the game and the other not. And also sometime the leader board doesn’t appear. I’m using socket and flaks and threads. If anyone can help me I would appreciate it

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

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

Python Daily

Help / Advice on Datatables in Django

Hi there,

I'm making a website that displays a lot of dynamic tabled data. After doing a bunch of research, I've sort of settled on Datatables - a JS library for displaying the tables that looks quite 'modifiable' and that's to my liking.

I'm using Django and Tailwind, and I've now noticed that Datatables overrides and messes up the Tailwind styling on my page even if I put the Tailwind CSS after the Datatables but I suspect because I'm loading in my tables with HTMX and initializing them after the swap that it reloads the DT CSS.

What does everyone else use when it comes to displaying tables? I like DT because it gives easy sorting and column highlighting and searching and all that jazz which is sort of what I'm after.

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

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

Python Daily

Starting My Startup Journey

I recently started my startup journey with my project, https://trytodue.com/. I had this idea during my freshman year of college because I hated manually entering my assignments into my Google Calendar. So, I am working on a project that automatically does it for you! Check it out and join the waitlist if you're interested!

https://preview.redd.it/jf4ahdp4h0pd1.png?width=2992&format=png&auto=webp&s=9ed7642d8216c3a80fdf88ad178f1783b6bc2e15



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

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

Python Daily

Which DB to use with my Flask app?

Hello! I'm working on designing a Flask app for an education project and trying to decide how to implement its DB. The web app is essentially a series of multiple choice / FITB / other types of Q&A behind a log in for each student. I expect that at its peak, about 60 students will be using the app simultaneously. Given they'll be answering lots of questions in succession, and I'll be writing their answers to the database, I expect the application will be both read and write-intensive. I've read that SQLite doesn't work as well for write-intensive applications, so my hunch is that a cloud MySQL server that I beef up during peak usage will be the best approach, but I wanted to get other opinions before committing. Thoughts, questions, or concerns?

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

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

Python Daily

Deploying a Django app with Kamal, AWS ECR, and Github Actions
https://dylancastillo.co/posts/deploy-a-django-app-with-kamal-aws-ecr-and-github-actions.html

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

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

Python Daily

Ruby on rails vs Django vs Laravel (Startup edition)

Hi, whats your honest opinion on Ruby on rails vs Django vs Laravel ?

Personally i have used all three of them just because of curiosity, what i have learned is:

- Ruby on rails -

If you use linux then i recommend learning ror because some of the gems or installation errors is pain in windows.

The scaffolding is just amazing. You only need one command to create crud which gives you both json for api and web routes.

Nowdays it uses hotwire which comes deafult. Its just like ajax so your website feels lil bit like SPA.

Best for - Livestream websites, very fast developement and get your product to market compared to django or laravel, hard to find good developers.

Downside i faced - No good tutorials, errors in windows, no community.



- Django -

The App is amazing like you can just create a feature and use it in any other project.

The Admin is very useful im impressed with it.

Feels like i have to write much more code compared to ror or laravel.

Open source and control over everything.

Best for - Social media, scalability and adding more features as website grows, AI/ML is the future, very easy to find good developers.

Downsides i faced - No

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

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

Python Daily

404 Error: Page Not Found

Hello, sorry if this has been asked before. I am a newbie to Django and 'm trying to open an html file containing "Hello World!" text, however no matter what I try, I get a 404 error. I've tried changing the vews.py, urls.py, and I even changed the Django Debug to "False", but nothing works, and it's getting frustrating. I've looked up YouTube tutorials, Django tutorials, and online forums, but no matter what I try, I just can't get the stupid webpage to open. Any help is appreciated!

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

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

Python Daily

Why is Django so popular in startups?

Django is quite popular with startups. What are the main features of Django which makes startups adopt it?

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

Читать полностью…
Подписаться на канал