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

Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

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

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

Python Daily

Simon Willison: "Things I've learned serving on the board of the Python Software Foundation"

Pretty good insights on what the PSF is and how it relates to the Python language from Django co-creator Simon Willison:

https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/

The entire post is worth reading, but here are links to specific sections:

[What is the PSF?](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#what-is-the-psf)
The PSF employs staff
[A lot of this is about money](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#a-lot-of-this-is-about-money)
The PSF does not directly develop Python itself
[PyPI—the Python Package Index](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#pypi-the-python-package-index)
PyCon is a key commitment
[Other PSF activities](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#other-psf-activities)
Work Groups
[Acting as a fiscal sponsor](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#acting-as-a-fiscal-sponsor)
Life as a board member
[The kinds of things the board talks about](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#the-kinds-of-things-the-board-talks-about)
Want to know more?

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

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

Python Daily

R First Published ML Paper - From a quick glance does anything stand out in terms of peer review notes?

# Long story short I've published my first paper through a conference proceeding, but my peer review was a little short. I am wondering if anyone here with experience in time series forecasting or XAI has any notes for me? would be kindly appreciated. No problems if not.

https://dl.acm.org/doi/abs/10.1145/3674029.3674035 (Is open access under ACM).

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

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

Python Daily

Service Reliability Math That Every Engineer Should Know

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

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

Python Daily

Open-source Dash app that features dashboards with varying levels of complexity

What My Project Does: This Dash app, whose source code is available here, demonstrates how to use Dash to create a series of interactive online visualizations, ranging from from simple charts to more complex interactive setups.

Target Audience: These dashboards and their corresponding source code will hopefully serve as a useful reference for developers who are evaluating different ways to represent data using Dash.

Comparison: This project has been released under the MIT license and thus offers developers more flexibility than projects released under more restrictive terms. In addition, this app may be more cost-effective than ones created with propietary tools like Tableau, as such tools may require the user to pay a significant amount in licensing fees. Finally, the live demo (available via the following link) allows users to easily review each of the sample dashboards.

Click here to view the Google Cloud Run-hosted version of this app. (If no one has accessed the app recently, it will take several seconds to load, as the app is set to run on demand in order to save costs.)


## Dashboard overviews:

The Fixed Dashboard page shows a very simple dashboard setup that lacks user-defined filter and comparison settings.


The Simple Interactive Dashboard

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

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

Python Daily

Maelstrom 0.12.0: Isolate your tests, and run them fast.

We’re excited to announce Maelstrom 0.12.0, a test runner for Python that can run tests locally or on a cluster. Our new UI features real-time information about running tests, output from the build, and a new progress bar.

Maelstrom is a suite of test runners, built on top of a general-purpose clustered job engine. Maelstrom packages your tests into micro-containers, then distributes them to be run on an arbitrarily large cluster of test-runners, or locally on your machine using a custom-built, super-fast container runtime.

https://github.com/maelstrom-software/maelstrom

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

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

Python Daily

I don't know shit about my project

I want to build and deploy a SpongeBob API similar to the One Piece API and I was having a couple of questions that maybe some of you can help me with

1.- Is it legal? I'm not quite sure what data can I and cannot use. For instance I'm pretty sure I can't use images from the show, but what about data about characters, places, songs related to SpongeBob. The whole point of this is to finally have something mine on internet and people can see it, if I can't show this legally I don't see the point on bulding it

2.- Can I have a section to receive donations? (again, is it legal?)

3.- Is it a good idea/practice to use the same django project for the web app (documentation, about page, donations, contact) and for the API? Or is it better to make 2 different projects and maybe different frameworks/libraries for the front?

4.- what security concerns do I have to keep in mind? I want it to be a public API I was thinking about limiting the request per minute and maybe store the data in the cache to improve perfomance, what else do I

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

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

Python Daily

I created a modern and customizable tooltip library for PyQt and PySide

Hey guys,

since I couldn't find any good libraries for showing modern-looking and customizable tooltips in PyQt, I made one myself.



What My Project Does:

It supports fixed placement, automatic placement, fallback placements, an optional triangle, animations, delays and much more. Basically anything can be completely customized and it's extremely easy to use. Also, since it's developed with QtPy, an abstraction layer for multiple versions of PyQt and PySide, you can use it with PyQt5, PyQt6, PySide2, and PySide6.



Target Audience:

This is useful for any Python developer who is working with PyQt or PySide and wants to add modern and customizable tooltips to their application.



Comparison:

To my knowledge, there are no comparable libraries out there.



Preview image: https://github.com/user-attachments/assets/0313ffc7-560b-4665-a652-e1e2601fcbaa

Demo video: https://github.com/user-attachments/assets/fa768d30-f3cc-4883-aa8b-fed3a8824b23

Github: https://github.com/niklashenning/pyqttooltip



Hope some of you will find this useful :)

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

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

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

I made an (opinionated) little Django DRF API template for anyone to use

This template focuses on my take for a nice and realistic Django developer experience.

Github repo: https://github.com/laaraujo/django-api-template

* Containers (Docker and Compose) for anything but tests
* Django Rest Framework
* PostgreSQL (sqlite3 for automated tests)
* Pytest + Coverage for testing
* Djoser for authentication (with email + password auth by default)
* Automatically generated API docs
* Whitenoise for static file serving (docs and admin)
* Pre-commit hooks for linting (ruff)
* A nice and clean Makefile for local dev env commands
* Github Actions for running tests on push and/or PR submissions
* Dependabot with monthly checks

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

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

Python Daily

Best Django learning books from zero to very expert?

What books do you recommend that will teach you Django from the beginning phase to the most deeply and very advanced one?

Thank you in advance!

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

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

Python Daily

Best way to communicate database updates to Flask web app?

Hello, I'm writing a simple flask app that displays a table containing rows of detection records. These detection records come from a sqlite db that is populated by a classifier python script. Both the web app and the classifier are run by main.py, that uses multiprocessing to spin up each process.

The app currently works, but I need to refresh the web page to show any new detection records that are inserted into the database after the page is loaded. I would like this to instead be a live page that automatically updates the table when a new record is inserted into the database. I figured the best way to do this would be to use flask socketio and pass a multiprocessing queue to both the web app and classifier, and then insert a detection into the queue at the same time the record is added. Then, within the web app, spin up another two processes: one for the web app, and the other being a consumer that is constantly watching the queue and calls the socketio emit whenever a detection is pulled from the queue. This doesn't work, and I'm curious if it is

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

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

Python Daily

Help me optimize my table, Query or DB

I have a project in which I am maintaining a table where I store translation of each line of the book. These translations can be anywhere between 1-50M.

I have a jobId mentioned in each row.

What can be the fastest way of searching all the rows with jobId?

As the table grows the time taken to fetch all those lines will grow as well. I want a way to fetch all the lines as quickly as possible.

If there can be any other option rather than using DB. I would use that. Just want to make the process faster.

This project is made in Django, so if you guys can provide suggestions in Django, that would be really helpful.

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

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

Python Daily

Edifice is like React, but with Python instead of JavaScript, and Qt Widgets instead of the HTML DOM

Edifice v1.0.0 was released last month.

https://github.com/pyedifice/pyedifice

Edifice offers a declarative framework for Qt which is like React, but with Python instead of JavaScript, and **Qt Widgets** instead of the HTML DOM.

# What My Project Does

- Modern declarative UI paradigm from web development.
- 100% Python application development, no language inter-op.
- A native Qt desktop app instead of a bundled web browser.
- Fast iteration via hot-reloading.

# Target Audience

Developers who want to make a desktop user interface in Python because their useful libraries are in Python (think PyTorch).

# Comparison

## Edifice vs. Qt Quick

Qt Quick is Qt’s declarative GUI framework for Qt.

Qt Quick programs are written in Python + the special QML language + JavaScript.

Edifice programs are written in Python.

Because Edifice programs are only Python, binding to the UI is much more straightforward. Edifice makes it easy to dynamically create, mutate, shuffle, and destroy sections of the UI. Qt Quick assumes a much more static interface.

Qt Quick is like DOM + HTML + JavaScript, whereas Edifice is like React. QML and HTML are both declarative UI languages but they require imperative logic in another language for dynamism. Edifice and React allow fully dynamic applications to be specified declaratively in one

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

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

Python Daily

Best library for creating graphic PDF documents?

I have an application for which I need to auto-generate some diagrams as PDF files. The graphics aren't anything particularly fancy, just line drawings and some text.

My first instinct was to generate LaTeX code in Python to draw the graphics with TikZ, but I feel like there's probably a better way without the middleman. I see there are a variety of different libraries for generating PDFs, so I'm looking for someone who has used one or more of them to maybe point me towards one which would suit my needs the best.

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

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

Python Daily

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

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

Python Daily

Is every backend framework just an API at this point?

Is spring, flask, django .NET, node, etc all just functioning as APIs at this point?

Most apps you're building are probably built with a javascript framework like react in the frontend and then one of the languages/frameworks I mentioned above as a backend?

If that's the case ,what is the point of jinja, making forms etc in flask/django? I suppose we shouldn't practice this and just go straight to building APIs only and if that is the case, why aren't we all just using FastAPI? What's the point of Flask/Django?

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

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

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

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