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

matplotlib tutorial - Spyder 6 IDE

I've put together a matplotlib tutorial video which should be a good primer for beginners. The video uses the Spyder 6 IDE and its visual aids such as its variable explorer:

https://www.youtube.com/watch?v=VNvg12tpLCM

Covering:

Importing the library and library overview
Procedural Syntax
Plot Backend (Inline vs Qt)
Visually Inspecting a Figure using the GUI
Colors
Subplot (Procedural)
Object Orientated Programming Syntax
Recall Parameters
Get Current Figure and Current Axes
Subplots (OOP)
Subplot Mosaic
Add Axes
Math and TeX
Linked Axes
Tick Parameters and Spines
Saving the Figure to an Image File
2D Axes and Specialised Polar Axes and 3D Axes
Polar Plot
Annotation
Getting and Setting Properties (Line Plot)
Scatter Plot
Marker Styles
lines and axline
Bar Plot
Hatching
Pie Chart
Histogram
Box Plot
Violin Plot
Histogram 2D
Hexbin
Meshgrid and 3D Data
Matrix Show
Plot Color
Colormaps
Plot Color Mesh
Contour and Contour Filled Plots
3D, Surface and Wiregrid Plots
Animation
Image Show
Tables
Matplotlib Configuration File

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

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

Python Daily

I wrote a tool for efficiently storing btrfs backups in S3. I'd really appreciate feedback!

What My Project Does

btrfs2s3 maintains a tree of incremental backups in cloud object storage (anything
with an S3-compatible API).

Each backup is just an archive produced by btrfs send [-p].

The root of the tree is a full backup. The other layers of the tree are incremental
backups.

The structure of the tree corresponds to a schedule.

Example: you want to keep 1 yearly, 3 monthly and 7 daily backups. It's the 4th day of
the month. The tree of incremental backups will look like this:

- Yearly backup (full)
- Monthly backup #3 (delta from yearly backup)
- Monthly backup #2 (delta from yearly backup)
- Daily backup #7 (delta from monthly backup #2)
- Daily backup #6 (delta from monthly backup #2)
- Daily backup #5 (delta from monthly backup #2)
- Monthly backup #1 (delta from yearly backup)
- Daily backup #4 (delta from monthly backup #1)
- Daily backup #3 (delta from monthly backup #1)
- Daily backup #2 (delta from monthly backup #1)
- Daily backup #1 (delta from monthly backup #1)

The daily backups will be short-lived and small.

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

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

Python Daily

Just starting django docs and I encountered a problem..

Am at this part of "Django Overview" after having installed Django, activated venv etc, and when I type in

from news.models import Article, Reporter

it says the news module is not there. Why is that?

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

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

Python Daily

I built a Multithreaded HTTP Server in Python

Hey everyone! I've built a simple multithreaded HTTP server from scratch in Python. It can handle multiple client connections at once, supports GET requests, and serves static files like HTML and images.

If you're interested, check it out on github and feel free to contribute or raise issues! Would love your feedback.

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

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

Python Daily

Push notifications using pushover api

what my project does:

conveniently can be imported into existing python package and initialized with your own api key/token, sends text notification or image notification to where ever the pushover app exists. logs notifications sent per device or all devices. logs can be reviewed in local json file


Target Audience:

Anyone that has a raspberry pi or server they monitor can send push notifications instead of cluttering their email inbox more. if you have a raspberry pi set up with camera can send push notification if movement is detected


comparison:

I could not find anything else out there like this, so decided to create one

check it out here: source code

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

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

Python Daily

It's time to stop using Python 3.8

14% of PyPI package downloads are from Python 3.8 (https://pypistats.org/packages/__all__). If that includes you, you really should be upgrading, because as of October there will be no more security updates from Python core team for Python 3.8.

More here, including why long-term support from Linux distros isn't enough: https://pythonspeed.com/articles/stop-using-python-3.8/

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

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

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

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

Python Daily

Guidance with a Django project front-end

I will be building a project for a client that involves developing an application to display data uploaded via Excel files. The application will include Google Maps integration, and data access will be role-based. Additionally, it will feature JWT-based authorization, along with login and logout functionality.

I have experience working with Django, primarily from building an user management system where I managed most of the functionality through the admin panel, which worked well for that project.

However, I’m currently struggling with the front-end design of my new project. Is it possible to use a theme for this? If so, how can I implement one? I would really appreciate any recommendations for tutorials that focus on modern design for Django applications.

While I’ve used admin panel themes before, I’m unfamiliar with applying themes to other parts of a Django project. Any guidance would be helpful!-

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

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

Python Daily

Which Authentication Method is Most Commonly Used in Django DRF?

Hello seniors, I've been learning about authentication in Django DRF and came across different methods like session-based authentication, token authentication, JWT tokens, and OAuth2. Each of these authentication types has its own advantages and disadvantages.

I'm curious to know which authentication method is most commonly used in the industry today.

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

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

Python Daily

Whisper realtime hallucinations using Python...Open AI and .CPP models.

Does anyone have experience fixing hallucinations with Open AI Whisper and Whisper.cpp models when using realtime. All code is running via Python. Models tried from Tini to Large V3 both Open AI original models and .cpp verions for Metal.

Models are doing OK job with constant audio stream..however when audio hits silent (no one talking) or just mutes - then both Open AI and .cpp models seriously hallucinate by displaying "thank you, thank you, you, thank you....." and so on. none stop. Very annoing when you trying to put this to screen for monitoring.

Did some digging and so far no def answer on the fix (some tried and gave up)


Just checking if anyone has actually came across a fix. As specific parameters? not sure if for 3sec chunks VOD would be solution? or some kind of masking / filtering out?


Little lost on this, as: options: 1) Give up on whisper for this application 2) Is there actually a solution I am missing?


If anyone think they do have solution :) happy to pay for the correct answer if it fixes it!!


Thanks any way and all comments / suggestions are appreciated!

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

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

Python Daily

maestro, a command-line music player

[https://github.com/PrajwalVandana/maestro-cli](https://github.com/PrajwalVandana/maestro-cli)

**What My Project Does**

maestro is a command-line tool written in Python to play music in the terminal. The idea is to provide everything you could possibly think of for your music experience in one place.

**Target Audience**

Anyone who listens to music!

**Comparison**

Lots of stuff that the big-name services don't have, such as tagging (instead of playlists), a built-in audio visualizer, free listen-along feature (think Spotify Jams), lyric romanization, listen statistics, etc. See the list of features below/in the repo for more!

Unfortunately, you *do* have to download your music to use `maestro`.

**Features**:

* cross-platform (obviously including Linux, that's why I posted it here lol)!
* someone got it working on their Linux phone?? crazy stuff
* add songs from YouTube, YouTube Music, or Spotify!
* stream your music!
* read the technical breakdown here: [https://github.com/PrajwalVandana/maestro-cli/blob/master/data/maestro\_listen\_along.pdf](https://github.com/PrajwalVandana/maestro-cli/blob/master/data/maestro_listen_along.pdf)
* lyrics!
* romanize foreign-language lyrics
* translate lyrics!
* clips! (you can define and play clips for a song rather than the entire song)
* filter by tags! (replacing the traditional playlist design)
* listen statistics! (by year and overall, can be filtered by tag, artist, album, etc.)
* shuffle! (along with precise control over the behavior of shuffling when repeating)
* also "bounded shuffle", i.e. a

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

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

Python Daily

Fake recruiter coding tests target devs with malicious Python packages

https://www.reversinglabs.com/blog/fake-recruiter-coding-tests-target-devs-with-malicious-python-packages

Remember to not execute untrusted code when doing code interviews.

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

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

Python Daily

Are celery jobs reliable?

Hey everyone,

I have a product that currently uses fastapi+sqlite3 to implement the mvp. I have a scheduled task in fastapi to do a few python things every hour. Currently, it's been working great for me.

Looking to scale up my project and just wondering if celery is a reliable solution. I'll probably be using cookiecutter-django since it's built in and should workfor this project, but just wondering if celery is the right choice for this. It's important that it runs every hour.

Any advice would be appreciated,
Thanks!

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

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

Python Daily

DBOS-Transact: An Ultra-Lightweight Durable Execution Library

**What my project does**

Want to share our brand new Python library providing ultra-lightweight durable execution.

https://github.com/dbos-inc/dbos-transact-py


Durable execution means your program is resilient to any failure. If it is ever interrupted or crashes, all your workflows will automatically resume from the last completed step. If you want to see durable execution in action, check out this demo app:

https://demo-widget-store.cloud.dbos.dev/

Or if you’re like me and want to skip straight to the Python decorators in action, here’s the demo app’s backend – an online store with reliability and correctness in just 200 LOC:

https://github.com/dbos-inc/dbos-demo-apps/blob/main/python/widget-store/widget_store/main.py

No matter how many times you try to crash it, it always resumes from exactly where it left off! And yes, that button really does crash the app.

Under the hood, this works by storing your program's execution state (which workflows are currently executing and which steps they've completed) in a Postgres database. So all you need to use it is a Postgres database to connect to—there's no need for a "workflow server." This approach is also incredibly fast, for example 25x faster than AWS Step Functions.

Some more cool features include:

* Scheduled jobs—run your workflows exactly-once per time interval, no more need for cron.
* Exactly-once event processing—use workflows

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

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

Python Daily

Django E-commerce (Pharmacy Management): My Learning Project – Feedback Wanted!



I’m excited to share a project I’ve been working on as part of my journey to learn **Django**: **E-commerce** (Pharmacy Management) 🎉 This web application, built with **Django Rest Framework**

**Key Features:**

* 🔐 **User Authentication**
* 🛒 **Product Management**
* 🏪 **Pharmacy Management**
* 👤 **Profile Management**
* 📝 **Prescription Handling**
* 📦 **Order Management**
* 💳 **Secure Payments**
* 📂 **File Management**

**Technologies Used:**

* Django Rest Framework
* PostgreSQL
* Django Allauth, Simple JWT
* Swagger
* Docker, GitHub Actions, Nginx
* Dropbox for file management

**Hosting:**

* Deployed on **Azure** using **GitHub Actions** for continuous integration and deployment

**Github** [link](https://github.com/MohamedHamed12/E-commerce-Pharmacy-Back-End)

[https://github.com/MohamedHamed12/E-commerce-Pharmacy-Back-End](https://github.com/MohamedHamed12/E-commerce-Pharmacy-Back-End)

I’d love to hear any feedback or suggestions

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

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

Python Daily

Sunday Daily Thread: What's everyone working on this week?

# Weekly Thread: What's Everyone Working On This Week? 🛠️

Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!

## How it Works:

1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.

## Guidelines:

Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.

## Example Shares:

1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!

Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟

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

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

Python Daily

D Why are most Federated Learning methods so dependent on hyperparameters?

I'm doing research in FL for some time now and went through a few subfields. Whenever I start a new project and do some benchmarking of existing methods, it always takes an eternity to get the methods to work on standard datasets like cifar10 that weren't used in the original papers. Currently I am using a premade benchmarking tool (fl-bench) and still struggle to get fedavg to converge on even slightly non-i.i.d. datasets on cifar10. This makes working in the field super frustrating imo. Did you have similar experiences or is there something fundamental that I missed all this time?

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

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

Python Daily

Reading Serial data and deploying it on FLASK

Hey everyone, hope you're all doing well. For the past two weeks, I've been stuck on my internship task, which involves reading data serially from an ESP32. The device is a machine maintenance system using a fluxgate sensor, DHT11, and a gyroscope. It serially sends data (x, y, z, total, temperature, and timestamp). My task is to read the data from the serial port and display it on a Flask web page using JavaScript. Every time I run the code in VS Code, I get an error saying "Port access denied." I'm not sure why this is happening, as no other IDE is running in parallel. I can provide the code if some one wants to figure out.



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

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

Python Daily

Exploring a Document’s Timeline in JupyterLab
https://blog.jupyter.org/exploring-a-documents-timeline-in-jupyterlab-6084f96db263

/r/IPython
https://redd.it/1fgbrbz

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

Python Daily

Can we talk about Numpy multi-core?

I hate to be the guy ragging on an open source library but numpy has a serious problem. It’s 2024, CPUs with >100 cores are not that unusual anymore and core counts will only grow. Numpy supports modern hardware poorly out of the box.

There are some functions Numpy delegates to BLAS libraries that efficiently use cores but large swaths of Numpy do not and it’s not apparent from the docs what does and doesn’t without running benchmarks or inspecting source.

Are there any architectural limitations to fixing Numpy multicore?

CUPY is fantastic well when you can use GPUs. PyTorch is smart about hardware on both CPU and GPU usage but geared toward machine learning and not quite the same use case as Numpy . Numba prange is dope for many things but I often find myself re-implementing standard Numpy functions. I might not be using g it correctly but DASK seems to want to perform memory copies and serialize everything. Numexpr is useful sometime but I sort of abhor feeding it my code as strings and it is missing many Numpy functions.

The dream would be something like PyTorch but geared toward general scientific computing. It would natively support CPU or

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

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

Python Daily

D Simple Questions Thread

Please post your questions here instead of creating a new thread. 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.

Thanks to everyone for answering questions in the previous thread!

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

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

Python Daily

Free tool to convert Jupyter notebooks into PDF (new features!)

Converting a notebook using the LaTeX-based converter and hiding the code

Hi r/IPython,

Two years ago, I announced here a tool to convert Jupyter notebooks to PDF for free.

The tool has now converted more than 10,000 notebooks! So I figured I'd add some extra features.

The tool is available at https://convert.ploomber.io

# New features

I started by adding a LaTeX-based converter, which is great for generating academic reports (previously, it only had a browser-based converter).
Switching the configuration now changes the URL, this will make it easier to bookmark your favorite settings. e.g. this link will select the "hide code" option and select the LaTeX-based converter

# Ideas

A few ideas I have:

Allowing to generate a static URL to see the notebook
Add Quarto as a conversion backend
Quarto would open a lot of possibilities for advanced formatting, so I thought of adding templates for exporting PDFs (e.g. one column, two columns, add table of contents)
Add support for other formats such as HTML and DOCX

Let me know what other things might be useful!

/r/IPython
https://redd.it/1fg0r3p

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

Python Daily

"Python Basics for Beginners: Examples and Best Practices"

Hi.

I’ve put together a guide to help beginners get started with Python. It covers everything from basic syntax and data types to more advanced topics like object-oriented programming and file handling. I’ve also included examples for control structures, functions, and data manipulation using libraries like NumPy and Pandas.

https://github.com/NaviReddy369/pythonexamples.git

Here's an outline of the topics covered:

1. Introduction to Python and setting up your development environment.
2. Basic syntax, data types, and control structures.
3. Functions, lists, tuples, dictionaries, and sets.
4. File handling and exception handling.
5. Object-oriented programming (OOP) basics.
6. Advanced topics like decorators and regular expressions.
7. Data analysis and visualization with NumPy, Pandas, Matplotlib, and Seaborn.
8. Basic web development using Flask.

Feel free to ask questions or share your own experiences with Python! Happy coding!

Naveen Kumar Gudimilla"

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

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

Python Daily

Feature Friday: Django's Database-Generated Fields

Need DB-generated values in your Django models? Meet the new GeneratedField!
Define fields with values created by the database, not Django. This is powerful for computed columns & more.

DB-generated fields can be used for the following use cases:

- Computed columns
- Default values from DB functions
- Auto-updating timestamps

Here's a small sample code showing the usage of GeneratedField:

from django.db import models
from django.db.models import GeneratedField

class Product(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=10, decimal_places=2)
discounted_price = GeneratedField(
expression=models.F('price') * 0.9,
output_field=models.DecimalField(max_digits=10, decimal_places=2),
db_persist=True
)


Some benefits of the DB-generated Fields:

- Improved performance: calculations done at DB level
- Data consistency: ensures all apps see the same generated values
- Reduced code duplication: no need to replicate DB logic in Django

Learn more: https://docs.djangoproject.com/en/5.0/ref/models/fields/#generatedfield

Are you using this feature? Do you think it's useful?

Note: This post is part of a new "feature friday" initiative from the Django Social Media team to create awareness around some of Django's lesser-known and newer features. Let us know if you have any feedback!

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

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

Python Daily

pyrtls: rustls-based modern TLS for Python

What My Project Does

pyrtls is a new set of Python bindings for rustls, providing a secure, modern alternative to the venerable ssl module. I wanted to allow more people to benefit from the work we've done to build a better alternative to OpenSSL-backed TLS, and figured Python users might be interested.

https://github.com/djc/pyrtls

Target Audience

This is basically an MVP. While the underlying rustls project is mature, the bindings are fairly new and could contain bugs. I'd be happy to get feedback from people eager to try out something modern (and more secure).

Comparison

Unlike the ssl module (which dynamically links against OpenSSL), pyrtls is distributed as a set of statically compiled wheels for a whole bunch of platforms and Python versions. It is backed by Rust code, which is all memory-safe (except some core cryptography primitives), and avoids older protocol versions, insecure cipher suites, and risky protocol features. The API is intended to be similar enough to the ssl module that socket wrappers can act as a drop-in replacement.

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

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

Python Daily

MPPT: A Modern Python Package Template

**https://datahonor.com/mppt/**

Hey everyone, I wanted to introduce you to MPPT, a template repo for Python development that streamlines various aspects of the development process. Here are some of its key features:

# Package Management

Poetry
Alternative: Uv, PDM, Rye

# Documentation

Mkdocs with Material theme
Alternative: Sphinx

# Linters

Ruff
Black
Isort
Flake8
Mypy
SonarLint
Pre-commit

# Testing

Doctest
Pytest: pytest, pytest-cov, pytest-sugar
Hypothesis
Locust
Codecov

# Task runner

Makefile
Taskfile
Duty
Typer
Just

# Miscellaneous

Commits: Conventional Commits
Change Log: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
Versioning: Semantic Versioning
License: [Choose an open source license](https://choosealicense.com/)
Badge: Shields.io
Contributing: [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/)
AI Reviewer: CodeRabbit

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

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

Python Daily

Web platform to share and execute scripts...

Hi everyone, we are developing several scripts in my team for our colleagues and as of now we package them in .exe files. We would like to change approach: is there a way to share scripts internally in a much easier way? Is Flask a good option for doing this?Thanks.

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

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

Python Daily

Will there be any problem if I learn from a Django 4 Book?

I wanted to get into Django, and I already had a book laying around Django for Beginners: Build websites with Python & Django 4.0.

I saw that there was a newer version of this book that teaches with Django 5, should I get that book, or is my book good enough?

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

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

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

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

Python Daily

Welcome to our new moderators 🌈

Hi r/django, you might have noticed in the sub’s sidebar we have a lot of new moderators here. Welcome u/Educational-Bed-8524, u/starofthemoon1234, u/thibaudcolas, u/czue13, u/Prudent-Function-490 ❤️


We’re all members of the Django Software Foundation’s new social media working group launched earlier this year, and have decided to see where we could help with this subreddit. Some of us have pre-existing experience with Reddit, others not as much. We’ll do our best to make it work! We’re very invested in the health of the Django community in those kinds of social online spaces. That includes moderation per Django’s Code of Conduct but also hopefully helping promote things that are relevant to our community.


Thank you for having us! We’re also really interested in any and all feedback about the subreddit.

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

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