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

Looking for a Django package to quickly add a blog to my existing project

Hey everyone!
I'm currently running a Django project and would like to add a blog feature to it. Is there a package or app that I can install to quickly set up a blog? Ideally, I'd want something that is easy to integrate into my existing project and doesn't require a full rebuild. Any suggestions for good blog packages, or should I just build one from scratch? Thanks in advance!

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

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

Python Daily

Cannot send JSON with template

I have a problem where it keeps escaping the quotation marks.

This is my code:

@app.route('/')
def home():
    gameslist = {"message": "Welcome to the Game Submission Page!"}
    dump = json.dumps(games
list)
    return rendertemplate('index.html', initialdata=gameslist)

and in my html

    <script>
        const initialData = "{{ initial
data }}"
        console.log(initialData)
    </script>

Console.log(initialData) produces "{\&#39;message\&#39;: \&#39;Welcome to the Game Submission Page!\&#39;}" regardless if I use json.dumps or not.

When I try "{{ initial_data | tojson }}" (also with "| safe") I get "Unexpected token '{'" when using json.dumps and without json.dumps I get "Unexpected identifier 'message'"

What am I doing wrong? Thanks.

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

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

Python Daily

django learning curve

how much time does it takes to learn django if i put in 1 hour per day is it doable by the end of this year given that i have done some leetcode problems and machinelearning basics using python.



and how does django compares to other frameworks in backend devolopment is it widely used in the industry


mods please delete this if its not allowed here

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

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

Python Daily

ryp: R inside Python

Excited to release ryp, a Python package for running R code inside Python! ryp makes it a breeze to use R stats packages in your Python projects.

https://github.com/Wainberg/ryp

/r/pystats
https://redd.it/1ftvafi

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

Python Daily

Need some advice on how to proceed with a project for multiple users on same network

so, im making a data entry form, where, the users can see all the data they've entrered, but the admin can see the data entries of all the users,

i started making the project yesterday, but was stuck in the authentication part, using mysql.

would appriciate the tips / pointers to move ahead

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

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

Python Daily

ryp: R inside Python

Excited to release ryp, a Python package for running R code inside Python!

[https://github.com/Wainberg/ryp](https://github.com/Wainberg/ryp)

ryp makes it a breeze to use R packages in your Python projects.

**What My Project Does**

ryp is a minimalist, powerful Python library for:

* running R code inside Python
* quickly transferring huge datasets between Python (NumPy/pandas/polars) and R without writing to disk
* interactively working in both languages at the same time

**Target Audience**

Data scientists and engineers, bioinformaticians, Python package developers, ...

**Comparison**

ryp is an alternative to the widely used [rpy2](https://github.com/rpy2/rpy2) library. Compared to rpy2, ryp provides:

* increased stability
* a much simpler API, with less of a learning curve
* interactive printouts of R variables that match what you'd see in R
* a full-featured R terminal inside Python for interactive work
* inline plotting in Jupyter notebooks (requires the `svglite` R package)
* much faster data conversion with [Arrow](https://arrow.apache.org/) (also provided by [rpy2-arrow](https://github.com/rpy2/rpy2-arrow))
* support for *every* NumPy, pandas and polars data type representable in base R, no matter how obscure
* support for sparse arrays/matrices
* recursive conversion of containers like R lists, Python tuples/lists/dicts, and S3/S4/R6 objects
* full Windows support

ryp does the opposite of the [reticulate](https://rstudio.github.io/reticulate) R library, which runs Python inside R.

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

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

Python Daily

Any state machine fans​ out there?​ Got any fun/awful stories?

I first started to appreciate finite state machines about 15 years ago when I was creating a custom radio protocol for low speed long distance links. Nothing too fancy, but the protocol had retries and acknowledgements. Like a tiny TCP stack.

About 8 years ago I became a state machine nerd out of necessity at work. Sink or swim. Although it was hectic, it pushed me to create a very useful state machine tool.

# The frickin huge LCD GUI

My first project at a new company was very ambitious for a solo dev. In a short amount of time, I needed to create a custom user interface for a 2x20 character LCD that had a lot of different menu pages. 107 pages in total, arranged into different hierarchies. Some of the menus were calibration and setup wizards. Some showed live data. Some were interactive and allowed editing parameters. Each of those 107 pages also needed to support multiple languages (English, German, Russian, Spanish).

A previous developer (that quit before I joined) had tried a data driven menu approach. They defined the entire menu layout and page transitions in data. This made perfect sense for a while until the client started adding tricky requirements

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

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

Python Daily

Rant of the Day

3 years ago I was working in tax when I got a taste for the potential of Python for problem solving. I got hooked and spent as much time as possible to understand Python for data analytics. I love using Python, idk but the feeling I get when a piece of code (written shitty) actually works....ahhh its amazing.
Kinda like Frankenstein.... "IT LIVESSSS!" Basically i really enjoy creating and solving problems with it.

Fast forward 3 years, and I managed to get a position of Senior Manager on Data Management, thinking ah yes finally I get to work on the things I like.

8 months in and I have YET to write a piece of code. Literally my entire time is spent replying to emails, fixing problems other people cause, having to deal with office drama, never ending meetings and top management seem to never be able to decide on anything. The amount of issues that come up on a daily basis is nuts and I never have time to sit down and be creative. Yesterday I lost my shit during a useless 4 hour meeting that could have been solved easily with a well

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

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

Python Daily

D Monthly Who's Hiring and Who wants to be Hired?

For Job Postings please use this template

>Hiring: [Location\], Salary:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] and [Brief overview, what you're looking for\]

For Those looking for jobs please use this template

>Want to be Hired: [Location\], Salary Expectation:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] Resume: [Link to resume\] and [Brief overview, what you're looking for\]

&#x200B;

Please remember that this community is geared towards those with experience.

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

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

Python Daily

I created a simple note taking application in Flask

Hey r/flask!

Been studying flask for a couple weeks and I wanna share with you a project I deployed on PythonAnywhere - check it out!

https://flasknotes.pythonanywhere.com/

You can build your own as well, I've provided a comprehensive README on GitHub.

https://github.com/ghandylan/flask-notes

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

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

Python Daily

I made some Python applications that may be useful for those interested in the self hosted world

There is a variety of apps that can be used via a docker container or by running standalone.

For details, see: https://github.com/TheWicklowWolf

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

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

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

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

Python Daily

Built a 360 Geo Guesser Game with Django

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


Recently built a Geo Guesser Game over the weekend, curious to see what feedback I could get on this project. I made a blog post in partnership with this project that can be found:
https://geomapindex.com/blog/Building%20a%20New%20Geo%20Guesser%20Game/

Play the game here:
https://dash.geomapindex.com/geo\_game\_select

Built in Django / Dash, custom components and UI just an initial release.

Specific input I'm looking for:

What do you like / don't like about the UI?

What location should I make the next game for?

What features would you like to see added?

etcetera..

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

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

Python Daily

Introducing ZipNN: A Python Library for lossless Compressing tailored for AI Models

**What My Project Does:**

ZipNN is an open-source Python library that enables lossless compression of AI models, **reducing their size by 33% with BF16 format (yes, also Llama3.2)**. Effectively cutting down download times and easing the load on servers. The library integrates smoothly with Hugging Face, with just adding a single line of code. The decompression is fast and there are already compressed Models on Hugging Face that you can try right away and save time.

**Target Audience:**

ZipNN is developed for **AI researchers, data scientists, and software developers** who manage large neural network models. It is particularly useful for those seeking efficient ways to handle model size constraints in both academic and production environments. The library aims to facilitate better resource management without sacrificing the accuracy of AI models.

**Comparison with Existing Alternatives:**

**ZipNN is tailored for AI models (the NN stands for neural network)** and gives both a better compression ratio and speed.
For example, with BF16, ZSTD (the current state-of-the-art) saves 21%, while ZipNN saves 33%, and compression and decompression are x1.5 faster.


**Additional Resources and Examples:**

* **GitHub Repository:** [Visit the ZipNN GitHub Repository](https://github.com/zipnn/zipnn)
* **Kaggle Notebook – Practical Example:** [Using ZipNN with Llama-3.2 on Kaggle](https://www.kaggle.com/code/royleibovitz/huggingface-llama-3-2-example)
* **Example Directory:** For more

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

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

Python Daily

deltabase: manage delta tables in both local and cloud environments with ease

What My Project Does: 

DeltaBase is a lightweight, comprehensive solution for managing Delta Tables in both local and cloud environments. Built on the high-performance frameworks **polars** and **deltalake**, DeltaBase streamlines data operations with features like upsert, delete, commit, and version control. Designed for data engineers, analysts, and developers, it ensures data consistency, efficient versioning, and seamless integration into your workflows.

Here is an Example Notebook using DeltaBase to explore some Magic The Gathering data.

Target Audience: data engineers, analysts, and developers

Comparison: fits somewhere inbetween using polars and deltalake directly and databricks

https://github.com/uname-n/deltabase

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

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

Python Daily

Heads up - until October 7, you can get 30% off PyCharm while donating to Django

Every year JetBrains and the Django Software Foundation partner on a great deal for everyone. You get a 30% discounted year of PyCharm, AND the DSF gets 100% of the money. It's basically making a donation to help support Django and getting a great product in return.

This is the DSF's biggest fundraising event of the year, and a great way to contribute back to Django while also picking up a world-class Python IDE in the process.

Django blog: https://www.djangoproject.com/weblog/2024/sep/23/pycharm-django-campaign-2024-encore/

Direct link to discount: https://www.jetbrains.com/pycharm/promo/support-django/

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

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

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

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

Python Daily

CORS and CSRF Configuration for a Separate Frontend and Backend? Willing to Pay

I have a website I am working on that uses Django and Svelte. Django acts as an API using Django Ninja. The frontend uses Svelte's SvelteKit framework and makes API calls to the Django backed. I have already created a github repo to hopefully make this easier and quicker: https://github.com/SoRobby/DjangoSvelteCookieAuth/tree/main.

The site is intended to be hosted on Digital Ocean (DO) on potentially two separate domains. Example of this would be below, where the frontend and backend are on separate subdomains.

Backend: https://example-backend-8lntg.ondigitalocean.app/

Frontend: https://example-frontend-gbldq.ondigitalocean.app/


Issue: I have been experiencing CORS and CSRF related issues that I can't seem to resolve. The site will use cookie-based authentication.

I have reached my threshold and am willing to pay ($200, via paypal or venmo) the first person that is able to solve these issues without sacrificing security, while remaining on Digital Ocean and deploying as an app and not a Docker container.

----

More details about the problem:
On the backend in settings.py, I have configured CORS, CSRF Cookies, and Sessions.

I am experiencing an issue that I cannot resolve and it relates to an error message of Forbidden (CSRF cookie not set.). On the frontend in Svelte, inside the hooks.server.ts file, whenever the frontend page is loaded,

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

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

Python Daily

Get clean markdown from any data source using vision-language models in Python

I have found that quality data preprocessing for LLMs from raw data sources can be an incredibly difficult task, so I'm sharing a new project I began working on this summer to solve this problem.

What My Project Does:

The package in question is an open-source project designed to simplify the process of scraping clean data from various sources (PDFs, URLs, Docs, Images, etc). Whether you're working with PDFs, web pages, or images, it can handle the extraction into a clean markdown format. Unlike traditional scraping tools, it is able to understand the context and layout of documents, thanks to vision-language models. It even handles complex tables and figures.

The beauty of The Pipe is that it's not just a black box. It's open-source so you can peek under the hood, understand how it works, customize it to fit your specific needs, etc. The Python library is quite thoroughly documented for this kind of stuff.

Comparison:

Look at existing Python packages for document scraping such as PyPDF2, Unstructured, PyMuPDF (fitz), PDFMiner, Tabula-py, Camelot, pdfplumber, and marker. While these tools are great at basic text extraction, they often struggle with more complex tasks like handling scanned PDFs, irregular data tables, tables that span multiple pages, and documents

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

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

Python Daily

Trending Django packages in September
https://django.wtf/trending/?trending=30

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

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

Python Daily

What Database should I use if I get to nearly 10k users?

If you were building a website with Django, would you stick with the Mysql bundled with Django to serve as database for over 10k users or use another DBMS?

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

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

Python Daily

The next great leap for Django
https://kodare.net/2024/10/01/django-next-leap.html

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

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

Python Daily

PyUiBuilder: The only Python GUI builder you'll ever need.

Hi all,

Been working on a Python UI Builder project for a while and wanted to share it with the community.

You can check out the builder tool here: **https://pyuibuilder.pages.dev/**

Github Link: **https://github.com/PaulleDemon/PyUIBuilder**

What My Project Does?

PyUIBuilder is a framework agnostic GUI builder tool for python. You can output the code in multiple UI library based on selection.

Some of the features:

While there are a lot of features, here are few you need to know.

Framework agnostic - Can outputs code in multiple frameworks.
Easy to use.
Pre-built UI widgets
Plugins to support 3rd party UI libraries
Generates python code.
Upload local assets.
Generates requirements.txt file when needed

Supported frameworks/libraries

Right now, two libraries are supported, other frameworks are work in progress

Tkinter - Available
CustomTkinter - Available
Kivy - Coming soon
PySide - Coming Soon

Roadmap

You can check out the roadmap for more details on what's coming [Roadmap](
https://github.com/PaulleDemon/PyUIBuilder/blob/main/roadmap.md)

Target Audience:

People who want to quickly build Python GUI
People who are learning GUI development.
People who want to learn how to make a GUI builder tool (learning resource)

Comparison (A brief comparison explaining how it differs from existing alternatives.)

Right now most available tools are library/framework specific.
Many try to give you code in xml instead of python making it

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

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

Python Daily

What are your thoughts on using Django as an SPA backend?

I’m leaning more towards FastAPI, so try and change my mind!

For context, the frontend would be a Nuxt SPA with SSR. I like the Django admin and ORM, but building a REST API with Django just seems easier in FastAPI. I’d be using Django Ninja as I don’t want to pay for Django Rest Framework if I monetize the app (I can’t get past the “strongly encouranged to sign up for a paid plan” if the app is commercial).

Would you use Django or FastAPI for building the backend for an SPA?

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

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

Python Daily

Beginner Question - Why API?

I've recently been learning Django via tutorials and books solely as a personal challenge as I don't use coding in my career. That said, I am struggling to understand why REST API's (or API's in general), exist. I have created a blog API in a tutorial, but why? Beyond extracting data from a huge database, why isn't a regular website with data presented in html sufficient? As a corollary, what would be a good personal project that could utilize an API vs./on top of a standard django website?

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

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

Python Daily

Ban Transparency from Tim Peters

Tim has posted a summary of communications he had with the PSF directly prior to his recent 30-month suspension.

https://chrismcdonough.substack.com/p/ban-transparency-from-tim-peters

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

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

Python Daily

Why use Django when we have FastAPI for small userbase applications

People often mention that Django comes with ORM and admin support. However, I can use SQLAlchemy or raw SQL queries as well. While Django has built-in admin features, FastAPI offers a full-stack template repository with React, which has pretty decent features that meet most requirements. FastAPI is also fast due to its asynchronous nature and has a growing, enthusiastic community eager to help.

Am I wrong in saying this? Give me good reasons to use Django.

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

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

Python Daily

(Almost) Pure Python Webapp

What My Project Does

It's a small project to see how far I can go building a dynamic web application without touching JS, using mainly htmx and Flask. It's an exploratory project to figure out the capabilities and limitations of htmx in building web applications. While it's not production-grade, I'm quite satisfied with how the project turned out, as I have learned a great deal about htmx from it.

https://github.com/hanstjua/python-messaging

Target Audience

It's not meant to be used in production.

Comparisons

I don't see any point comparing it with other projects as it's just a little toy project.

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

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

Python Daily

Why iommi is so… weird
https://kodare.net/2024/09/30/why-iommi-is-weird.html

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

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

Python Daily

Paramorator – Simplify Parametrized Decorators, Make Type Checkers Happy ✅

In almost every project I work on I end up needing to create parametrized decorators at some point. That is, a decorator that can accept arguments before you tack it into the function or class you want to wrap. For example:

@database_session
def get_data(session: Session, key: str) -> dict[str, Any]:
...

@database_session(privileges="read_write")
def save_data(session: Session, data: dict[str, Any]) -> None:
...

It's not exactly rocket science, but to do this in a way that will make type checkers and IDEs happy can be a bit of a pain. [Paramorator](https://github.com/rmorshea/paramorator) is a dead simple (<100 line) library I created that makes that process a little easier. Here's how you could use it to implement the `database_session` decorator above:

from functools import wraps
from typing import Callable, Concatenate, Literal, ParamSpec, TypeVar

from paramorator import paramorator
from sqlalchemy.orm import Session

P = ParamSpec("P")
R = TypeVar("R")


@paramorator
def database_session(


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

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