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
Why is poetry such a mess?

I really wanted to like poetry. But in my experience, you run into trouble with almost any installation. Especially, when it comes to complex stuff like pytorch, etc. I spent hours debugging its build problems already. But I still don't understand why it is so damn brittle.

How can people recommend this tool as an alternative to conda? I really don't understand.

/r/Python
https://redd.it/131snt9
How to make @loginrequired optional?

hi, I have this piece of code:

@app.route('/register', methods=["GET", "POST"])
@loginrequired
def register():
if request.method == "POST":
...etc

Now, if I have no users in the database yet (so if User.query.count() == 0 I want it to be available without login so the initial user can be registered (which then has rights to create others) but how? I tried putting @login_required in an if statement but that doesn't work. What's the proper approach for this?

/r/flask
https://redd.it/131okwn
Piperoni ~ Create your business process diagrams with words!

Check out Piperoni, the graphical frontend for the ProcessPiper Python package! With Piperoni, you can easily generate business process diagrams using simple English words.

Piperoni Repo: https://github.com/csgoh/Piperoni
ProcessPiper Repo: https://github.com/csgoh/processpiper

Piperoni project is still in the early stages of development. Any feedback is welcome!

https://preview.redd.it/y6zvm2v3jlwa1.png?width=1834&format=png&auto=webp&v=enabled&s=9a78b01c15403512c52221858cf2c99c3b3fb156

/r/Python
https://redd.it/131myf1
SQLModel or SQLAlchemy for big data analysis application?

Hello i need some advice. We are working on a new data analysis software and i need to choose between SQLModel and SQLAlchemy for our backend , seeing as it's going to be a massive application and nobody in my company has much experience with python (all our other applications are in ruby on rails) i wanted to know some pros and cons on using SQLModel over SQLAlchemy.

Some pros for SQLModel:

1. Our data analysit use pydantic for modeling the input and output of our APIs.
2. We are going to use FastAPI.

Some pros for SQLAlchemy:

1. It has a history as a reliable library.
2. The last commit for SQLModel was 2 months ago and it's still a relatively new library.

Sorry if this post isn't allowed (if it isn't please tell me where to post). Thank you in advance.

/r/Python
https://redd.it/13260j3
Introducing Project Ragaz - A fast, safe and powerful pythonic compiler which aims allow you to create simple scripts to complex systems in a code easier to read, write and maintain than other system languages with the same purpose.

Hello everyone, I would like to introduce you to a project that I have been working on for 2 years. For those who don't know me, my name is David, I'm a software engineer (MSc) and I've been working with Python and artificial intelligence for a few years.

The name of the project is Ragaz, and it consists of a compiler aimed at meeting requirements that many developers, like me, have always wanted in the Python world as such as:

Runtime speed equal to or close to languages like C/C++ or Rust.
Compiling a Python project to pure executable code (using LLVM) without the need for virtual machines, wrappings, decorators, and other extras to distribute your software.
Code that runs on multiple processors (because there is no [GIL](https://granulate.io/blog/introduction-to-the-infamous-python-gil/)).
Rust-like memory management that eliminates garbage collector, improves runtime speed and prevents memory access bugs.

With these requirements already being met in my project, even creating an operating system in Python would be feasible, for example.

I made this chart comparing Ragaz's performance with the official version of Python and C/C++. As you can see, the program compiled in Ragaz runs at a speed close to the same one compiled in C/C++ and is dozens

/r/Python
https://redd.it/1329mfw
Django Roadmap

Can you provide a Django roadmap to help me improve my skills and knowledge as a developer?

/r/django
https://redd.it/131m4w0
Prefetchrelated and filtering

I was reading django documentation about [prefetch related](
https://docs.djangoproject.com/en/4.2/ref/models/querysets/#django.db.models.query.QuerySet.prefetchrelated)

And the next lines confused me a bit:

pizzas = Pizza.objects.prefetchrelated('toppings')
[list(pizza.toppings.filter(spicy=True)) for pizza in pizzas]


…then the fact that pizza.toppings.all() has been prefetched will not help you.
The prefetch
related('toppings') implied pizza.toppings.all(), but pizza.toppings.filter() is a new and different query. The prefetched cache can’t help here;

Can anyone explain what is meant by this? Why prefetch cache can't help in such cases?

/r/django
https://redd.it/13232zy
Databases Design

Hi!!
Im trying to create the ER schema but I’ve had some trouble since Database architecture isn’t my strength.
Basically, the app X has a service S. That service S has different functionalities such as: data analysis, and news analysis.
My problem is connecting the relations. So far I have this model:

1. Service Relation
—————————
Name

Price

Isactive

Functions (manytomany)

2. Functions relation
—————————-

Name

Is
active

3. News analysis
——————————-

Author

Pub date

Content

My desire is to somehow relate the service S, to the news analysis.
If you have any other ideas or thought about how to improve it please let my know.
I would appreciate any type of help.

/r/django
https://redd.it/132ag0t
slow backend

Hello folks,
I am a beginner programmer, I am trying to build a web application for my university project.
I have made a pipeline which is related to pharmacology studies.
I want to take user inputs from my website and use it in my pipeline to generate output.
To take user inputs i have made a form which takes in a list of diseases and a file and some other information.
My problem is that I am not able to use my pipeline code in flask app.
Actually my pipeline code takes few minutes of time to generate output which is saved in a file and will be given to user.
I have tried calling a function in flask app to integrate my pipeline code. But it is not working. The pipeline is generating output when used outside of the flask app but not when I integrate it in my app.
Any suggestions for this kind of problems?

Thankyou

/r/flask
https://redd.it/132ior4
Github CI/CD + Django

I want deploy my project, whenever there is pull request created for main branch. This should deploy my code to some subdomain. So that I can share with my team members. Onces complete testing and changes, upon successful merge of this PR in need to clear the setup code from my server except the environment. Looking for resources so that I can do so!
Note: I know Jenkins and other CI/CD tools still just looking for DIY type resources.

/r/django
https://redd.it/132lox8
P GPT + Machine Learning program, to generate product descriptions from photo - free to access

​

https://reddit.com/link/132nr0x/video/qrnfjhoyeswa1/player

Right now mainly focused on clothes, but other modules still works good.

Public tests if you are interested you can test it for free:

https://scribe.devopsbay.com

/r/MachineLearning
https://redd.it/132nr0x
Best way to send data to notebook from external program - socket?

Is it possible to send data to a Jupyter notebook from an external program and have it appear e.g. as variables accessible within the notebook that change live when the external program updates them?
At the moment I have to export data as a file and use code in the notebook to load it e.g. as CSV. The ideal would be if this can be done for both Python and Julia notebooks as I have some scripts with each language.

My idea is to perhaps open a socket within the notebook server that my external app can connect to, so I can send commands to update vars e.g. "x=1,2,3,... " , "y=3,6,8,4,...". I would like then variables x and y to automatically change in the notebook, and dependent calculations to be redone and plots automatically updated as a result.

/r/JupyterNotebooks
https://redd.it/132s7fz
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?

Use this thread to chat about and share Python resources!

/r/Python
https://redd.it/132duia
I tried to make automated YouTube videos using python

Hi everyone, We at Codingbridge tried to use AI to deliver Tech News Everyday, Here is how we did it

1) Use python and selenium to scrape tech related news

2) Preprocess textual data and add additional script

3) Create your own avatar using DeepFake .

4) Use text to speech model to convert textual data to wav format

5) Use MoviePy to cut the video in parts

6) Use Transformer Model to lip sync Video and Audio

7) Use MoviePy to add transitions and merge them in a single video file

8) Use Text to Image for Thumbnail

Here is the result please give your feedback
https://youtu.be/-sxZ2am4nRY

/r/Python
https://redd.it/132ichv
Introducing surveydown - an open source, markdown-based survey framework (that doesn’t exist yet)

Hi folks, I am developing a markdown-based survey platform, and before I go further in the dev work I wanted to carefully think about frameworks and goals, so I laid out my thoughts of the goals and features for this package in this blog post:

https://www.jhelvy.com/posts/2023-04-06-markdown-surveys/

I have a working prototype using Shiny (I am more experienced in R than Python), and I've put it up here: https://github.com/jhelvy/surveydown

But the more I tinker, the more I'm starting to thing that Python may be the better language for this given the many well-developed Python web frameworks out there. Here are some important desired features:

1. Ability to run code: This is perhaps the most important feature. A critical reason I want to build this is so that a user could use code to define aspects of their survey, e.g. randomizing information shown in questions, etc. I haven't seen a survey framework that allows users to run code inside the survey.
2. Markdown-based user interface: A user should be able to quickly define their survey using mostly plain markdown. Then they should be able to run a single command to compile those files into a live web-based survey.
3. Built-in database: Once the survey is compiled, it should

/r/Python
https://redd.it/1332tsx
You can't use pip on Ubuntu 23.04 anymore

so long story short you won't be able to run pip install x anymore. The reason why the command doesn’t work in Ubuntu 23.04 is because of an intentional shift in policy to avoid conflicts between the Python package manager(pip) and Ubuntu’s underlying APT. You can now only use pip by creating a virtual environment with venv. My question is, is this a good thing or a bad thing? is it a good move from Ubuntu's team or not? being able to use pip only from a virtual environment. idk what do you guys think about the whole thing?

/r/Python
https://redd.it/1338oge
Case insensitive username with djangos built user creation?

I noticed when I create a dummy user with capitals and then I got to log in with all lower. it says user doesnt exist.

How can I default username to lower case? I am using Widget_Tweaks to style the form.

Here is my forms.py

from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms

class RegisterForm(UserCreationForm):
email = forms.EmailField(label='', widget=forms.TextInput(attrs={'class:':'form-control', 'placerholder':'Email Address'}))
firstname = forms.CharField(label='', widget=forms.TextInput(attrs={'class:':'form-control', 'placerholder':' First Name'}))
last
name = forms.CharField(label='', widget=forms.TextInput(attrs={'class:':'form-control', 'placerholder':'Last Name'}))

class Meta:
model = User
fields = ('username', 'firstname', 'lastname', 'email', 'password1', 'password2')

def init(self, args, kwargs):
super(RegisterForm, self).__init__(
args, kwargs)



/r/djangolearning
https://redd.it/1339yi2