Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Component sources

Are there any sources for making templates that can act like components?

Sort of how react libraries have material where they have docs on how to use their β€œselect” widget

Is there any source like that for Django otherwise I have to make my own custom stuff

/r/django
https://redd.it/1gjx43h
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/1gjtaue
Rio: WebApps in pure Python – A fresh Layouting System

Hey everyone!

We received a lot of encouraging feedback from you and used it to improve our framework. For all who are not familiar with our framework, Rio is an easy-to-use framework for creating websites and apps which is based entirely on Python.

From all the feedback the most common question we've encountered is, "How does Rio actually work?" Last time we shared our concept about components (what are components, how does observing attributes, diffing, and reconciliation work).

Now we want to share our concept of our own fresh layouting system for Rio. In our wiki we share our thoughts on:

* What Makes a Great Layout System
* Our system in Rio with a 2-step-approach
* Limitations of our approach

Feel free to check out our Wiki on our [Layouting System](https://github.com/rio-labs/rio/wiki/Layouting-System).

Take a look at our playground, where you can try out our layout concept firsthand with just a click and receive real-time feedback: [Rio - Layouting Quickstart](https://rio.dev/docs/howto/layout-guide)

Thanks and we are looking forward to your feedback! :)

[Github: Rio](https://github.com/rio-labs/rio)

/r/Python
https://redd.it/1gjgcsf
Task queue with asyncio support

I like Django for it's time and battle tested codebase. Its ORM is super intuitive to use. DRF fills in the gaps which allows me to define Schemas for my request validation and expose APIs as OpenAPI spec.

I process simple CURD requests within Django. For long running tasks, I am looking out to select a library which supports

* asyncio natively (I should be able to define my tasks as `async def`) [ Most of my long running jobs are io intensive and async native library will help me there ].
* ability to handle Django ORM use cases in the async tasks, like fetching and saving database objects (preferably using `sync_to_async`) till Django comes up with native support for asyncio in their ORM
* ability to send tasks to rabbitmq instead of redis (I like the stronger "exactly once", "message acknowledgement", "custom routing" etc. guarantees and functionalities provided by rabbitmq).

I have started to develop strong dislike for Celery's pre-forking model. The workers seem to crash without any particular reason, with Signal 11, Signal 5 etc. Celery does not also have async support natively, and I feel discomfort in monkey patching it using gevent.

Has anyone run into similar requirements? How did you

/r/django
https://redd.it/1gk3p5m
Staff Software Engineer VS Principal Software Engineer VS Senior Software Engineer

I have seen these positions all over linked in, however, what do they do? I have never seen Django as a requirement for one of those positions, what is the difference between them and a backend developer? are they full stack... I am clueless

/r/django
https://redd.it/1gk5x3w
Introducing jinpro -- Vue/React like components, all in Flask and Jinja

Hey all! Longtime lurker here.

I always really enjoyed the syntax of custom components in Vue, React, and other .JS frameworks, but hated the overhead of those frameworks, and also don't really like Javascript that much (if I did, I'd learn Node.js).

I checked high and low for something that did what I want, but the only one is a library called JinjaX -- and no matter how many times I read the documentation, it simply did not work on my machine. No errors, just... didn't do anything.

So, I write a really simple and small preprocessor that allows for this kind of behavior.
In essence, you create a file (like Button.jinja) and define what arguments it takes. Then, in your jinja templates for other pages, you call it like an HTML tag -- <Button color="red">Click ME!</Button>.

Finally, rather than using the built-in render_template function, you use the JinjaProcessor.render function, which behaves exactly like Jinja's render_template -- except it looks for those capital-letter tags, renders them into HTML with the template context, and then renders the whole page. It also works recursively, so components can call on other components (like a PageLayout calling on a Navbar).

It's available on github and PyPI (through pip).

jinpro on PyPI

jinpro

/r/flask
[https://redd.it/1gk1kg6
Help Django to reach 80k stars on GitHub 🌟

Django's first commit dates back to 2005 πŸš€

In all these years, it has freely shared all the new features πŸ€—

If you've ever used Django, put a star on its GitHub repository and share this post πŸ”„

https://github.com/django/django

/r/django
https://redd.it/1gk7y75
What Free Host Providers do you Use for deploying RESTful API ?

Until this moment I had using Render which provides a free limited plan for deoloying Python or any other API, pythonanywhere is another option which allow deploying for free.

If you're testing a project you need to deploy the API, where you do it for free?

/r/Python
https://redd.it/1gk5ayh
Flask OpenAPI Generation?

I've been exploring Python frameworks as part of my blog on Python OpenAPI generation and I was quite surprised to see that Flask requires an extension like flask-smorest to generate an OpenAPI specification. Is OpenAPI just not popular in the Flask API community or is smorest just so good that built-in support is not needed?

/r/flask
https://redd.it/1gkcdnu
Effect size calculation for Repeated measures Anova

Hello! Im running an analysis using python's statsmodels rm anova method. I have a 2 way repeated measures anova analysis and a series of 1 way repeated measures anovas. I want to calculate the effect sizes.

Since there isn't a direct function for retrieving the partial eta square measure, I figured I would have to calculate it. But to do that I require the sum of squares values. As far as I can tell, I can't retrieve those values either.

So my questions are:
1. Is there a way to retrieve or compute the sum of squares values? (Maybe I just missed it?)
2. Can I calculate the partial eta square value using the variables in the anova table (like the f value, degrees of freedom, p value etc)?

/r/pystats
https://redd.it/1gkbqjv
ELI5: Flask vs React (framework vs. library)

Flask: a micro-framework
React: a library

Since react is a library and libraries are considered to be un-opinionated, how is the (very proudly un-opinionated) Flask still considered a framework? is it due to routing, wsgi, etc. out of the box?

/r/flask
https://redd.it/1gkhr2i
R Never Train from scratch

https://arxiv.org/pdf/2310.02980

The authors show that when transformers are pre trained, they can match the performance with S4 on the Long range Arena benchmark.

/r/MachineLearning
https://redd.it/1gk7dny
Data analytics

Hi, I’m in a course on data analytics - our teacher keeps saying that we will find our niche within the spectrum of visualisation, machine learning or coding.
I’m not sure how that works? Like how are we supposed to get better at visualisation without mastering coding. At times he says coding is important if you are interested in becoming a junior data analyst. how does the job market work? Can someone explain it to me? I’m not sure where my strength lies.

/r/IPython
https://redd.it/1gkhjzb
Bokeh Plot Problem

Hi all, I'm trying to have two bokeh plots in a flask app with bootstrap columns. I need two.

They are setup as an html and one is loading fine and the other is not showing up.

In my main app.py:

#tell flask to read dashboard page
@app.route('/dashboard')
def dashboard():
# Read content of plot1.html
    with open("plot1.html", "r") as f:
        plot1_html = f.read()
   
    # Read content of plot2.html
    with open("plot2.html", "r") as f:
        plot2_html = f.read()
   
    # Pass both plots to the template
    return render_template("dashboard.html", plot1_html=plot1_html, plot2_html=plot2_html)

In the dashboard.html:

 <!-- map and chart in bootstrap setup-->
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-6">
     

/r/flask
https://redd.it/1gkiu8s
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/1gkl9r8
A recommendation for a simple job queue, for LAN/electric outage resilient app?

I'm developing a Flask application to handle incoming data via webhooks. The primary goal is to ensure reliable processing and delivery of this data, even in the face of potential power outages or network interruptions.

To achieve this, I'm considering a queue-based system to store incoming data locally, preventing data loss if anything happens to my infrastructure.

I initially explored Celery and Redis, but I'm facing challenges in implementing simple, resilient tasks like sending a request and waiting for a response. This leads me to believe that these tools might be overkill for my specific use case.

Given my lack of experience with queue systems, I'm seeking guidance on the most suitable approach to meet my requirements. Are there any recommended best practices or alternative solutions that could be more efficient and straightforward?

/r/flask
https://redd.it/1gk9mo6
Just published an article to understand Python Project Management and Packaging, illustrated with uv

Hey everyone,



I’ve just finished writing the first part of my comprehensive guide on Python project management and packaging. Now that I think about it, I think it's more an article to understand the many concepts of Python packaging and project management more than a guide in and of itself.


The article: A Comprehensive Guide to Python Project Management and Packaging: Concepts Illustrated with uv – Part I



In this first part, I focused on:

\- The evolution of Python packaging standards through key PEPs.

\- Detailed explanations of the main concepts like `pyproject.toml`, the packaging nomenclature, the dependency groups, locking and syncing etc.

\- An introduction to `uv` and how it illustrates essential packaging concepts.

\- Practical workflows using `uv` that I use with data science projects.


Mainly what it lacks is a deeper section or paragraph on workspaces, scripts, building and publishing. That's for part 2!



Working on this article was mainly journey for me through the various PEPs that have shaped the current Python packaging standards. I delved into the history and rationale behind these PEPs. I just wanted to understand. I wanted to understand all the discussions around packaging. That's something we deal with daily, so I wanted to deeply understand

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