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
What ORMs do you use and why?

Hello !
I am building a Flask application and up until now I've only used SQL queries.
But now I am building a larger application (a forum) and I am considering to use an ORM.
The biggest reason for this is to have a layer capable translating all my stuff to any relational DB.
Another thing is maintainability. It feels easier to implement models to be honest.
What ORMs do you use? I heard SQLAchemy is the most popular and the most "used in industry". But people call it off for being hard to use and having poor performance.
I found PonyORM and it looks like a great alternative. I love the syntax and how lightweight it is.
Also PeeWee seems interesting.
What ORMs do you use? And, why is SQLAchemy much more popular? Is it because of the name? What does SQLAchemy have that other ORMs don't have?

/r/flask
https://redd.it/1eiop9s
A script to batch convert media with ffmpeg

# What My Project Does

This is a Python script that batch-processes videos using ffmpeg. The script evaluates the list of input files and directories provided and converts all files to the specified output directory. The conversion is done with ffmpeg using the command line argument from one of the available presets.

It also provides a nice formatted output to the console with colors and progress bars.

# Target Audience

Myself and any other that has a bunch of media to transcode

# Comparison

Better than a batch file, there are colored progress bars to stare at for hours while the media is converted.

# GitHub

https://github.com/ts-manuel/ffmpeg-batch

/r/Python
https://redd.it/1eiywug
Flask to Quart

Migrated from Flask to Quart using the steps on this page: https://quart.palletsprojects.com/en/latest/how\_to\_guides/flask\_migration.html
Took about 15-20 minutes to get everything back up and running again. I had to use CoPilot to help fix a couple of glitches. Also, changed from gunicorn to uvicorn. Deployed and it seems to work. From what I read there is a 2-5 times performance improvement. I don't have metrics. But it "feels" faster and seems like an easy win. Want to hear what y'all have to say about this.

But question...what limitations and bugaboos have you run into with Quart in moving from Flask? Should I fully commit to Quart?

edit: Since both Flask and Quart are part of pallets project, they are not really "competing" frameworks. I mean, Quart may be where Flask is headed. Am I right?

/r/flask
https://redd.it/1eipr60
Pastebin Command Line App | PasteCMD

# What my Project Does?

PasteCDM makes using Pastebin much more simple, with a CLI app. As of now, you can:

1. Upload text sentences
2. Upload file contents

# Target Audience

Anyone who uses Pastebin service

# Comparison

N/A

# GitHub

GitHub Link: https://github.com/rohankishore/PasteCMD

/r/Python
https://redd.it/1eifw9u
Reasons why you love building with Django?

What are the reasons you love working with Django?

/r/django
https://redd.it/1ej59tz
How should I handle errors, aborts, logging and audits in my endpoint?

I have a login endpoint (api/auth.py) that receives the request, and uses an auth service (services/auth_service.py). Btw I'm using Flask for backend React for frontend.
I was handling things like this, for a clean endpoint, and letting auth_service to do the logic:

auth.py
@authbp.route("/login", methods=["POST"])
def login():
data = data.get
json()
response, status = AuthService.login(data)
return jsonify(response), status

authservice.py
class AuthService:
@staticmethod
def login(data):
email = data.get("email")
password = data.get("password")
if !validate
credentials(email, password):
abort(401, description="Email or password incorrect")

# Token creation here

return {"success": True, "accesstoken": accesstoken}, 200

So basically, anything other than a successful login triggers an abort. I had no problem with this,

/r/flask
https://redd.it/1ej975i
Django rest framework

Hey, everyone can you guys just suggest to me the best resource to learn django rest framework(drf) for beginners.

Also, I want to ask that I have the experience of backend development using NodeJS and express but I am confused do I have to learn about normal template based django first and then shift to drf or I can directly start with drf.

I have limited time so I want to learn it faster.

/r/djangolearning
https://redd.it/1ejge1t
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/1ejhq9s
Website To Easily Develop Tkinter GUIs

# What My Project Does

I've been working for a while in this project where you can easily create Tkinter Interfaces.

It's a website where you can just drag and drop widgets in a figma-like interface to customize them. Afterwars, you just gotta click Translate to Code and it will translate your interface to Tkinter Code!

# Target Audience

As a wise man once said DEVELOPERS DEVELOPERS DEVELOPERS! To make your life easier when creating tkinter interfaces!

# Comparison

I used to use a website called VisualTK, but it is down since a while.

# GitHub

https://github.com/arthurdeka/CustomTkinter-Templates/tree/main?tab=readme-ov-file
(First link on README)

/r/Python
https://redd.it/1ejcbhe
Python Skills for AWS

So if you want to be a great cloud engineer, you need Python scripting skills, Linux skills and some networking knowledge....What do i do

/r/Python
https://redd.it/1ejplk8
Is Learning Django REST Framework (DRF) Worth It?

I've recently started learning Django REST Framework (DRF), and I've noticed that many methods need to be overridden for even simple tasks. This made me wonder, why can't we just create APIs using Django itself? Is creating APIs using Django insecure or what?

I'd love to hear from the community about this. Is DRF worth the extra effort? What are the main advantages of DRF over Django for API development? Any insights or experiences would be greatly appreciated!

Thanks in advance!

/r/django
https://redd.it/1ejmz25
How to handle Blog data

Hey I've been following miguels tutorial and have a few questions:

What is the best way to handle blog data? I want to write multi page articles with gifs / images if possible. I have 2 ideas on how to handle this and wondering what is the generally accepted practice:

1. Create blog table with TEXT as field. Not sure how well it handles formatting like newline characters / whitespace etc. Requires me to then create a form / url and have to be logged into the website to write the articles. Probably easiest solution?
2. Create a directory with markdown files for my articles and have a blog table track the file location and meta data. This means I can write them in markdown somewhere else and don't need to make another form / url for writing them. Issue is how do i keep my db in sync with the blog, if the file names change, meta data changes, etc. Also how would i add new articles once the website it deployed? Copy paste somehow from my local machine to the server?
3. Another way?

Last question, how does rendering markdown work in the browser? Do i have any control over the

/r/flask
https://redd.it/1eiknlx
I need a custom flask header

* must be flask
* must be custom and none of the defaults
* cannot wrap and not allowed to use request methods
* may not chain load off app route, route_map, or return per handle
* must be custom header

/r/flask
https://redd.it/1eiu8js
Sideways Shooter game in Python. Python Crash Course, 3nd Edition.

Hi,

I'm new to programming and decided to pick up Python as first language. I recently completed Python Crash Course by Eric Matthes, and I must say it was a fantastic book.

I had so much fun creating the Alien Invasion game that I ended up making four variations of it.

I'm now moving on to Dead Simple Python to develop my skills while doing some solo projects.

If anyone is interested, you can check out the games I made here:

https://github.com/E-Rinaudo/first\_solo\_projects/tree/main/solo\_projects/games

Happy coding!

/r/Python
https://redd.it/1ejbvpj
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/1ejkdhj
Why is no one using full-stack python for web development? Has no one heard of the FHBH stack ??

Hey guys, I recently came across some libraries that seem to be very interesting to work with for the purpose of creating websites, but I wanted to know why no one uses them, or why they are not so widespread. I haven't had time to develop a more advanced and dynamic project with these libraries yet, but I believe that together they can be extremely useful, powerful and versatile for websites of any purpose. Maybe because no one knows about them, or because there is no benefit in using them and there are better ways to do it, but in a quick project test that I did, the dynamics of working with them seemed very interesting to me.

The libraries that I found were these:

**FastAPI**

A microframework for creating APIs, which can easily be used to create powerful websites.

**HTPY**

HTPY is a library that I recently discovered that was developed by a company that needed a better way to develop their projects with Django and created this library. It encapsulates HTML tags in Python classes, so that all HTML code can be created directly from a Python file, making it possible to use all the power that a programming language offers to generate

/r/Python
https://redd.it/1ejympc
Django Rest Framework vs Django Ninja for Api?

whats the difference between 2 and which one to choose for api development

/r/django
https://redd.it/1ejr7qj
db.createall() - Does not create *.db file. Help please

So I have been following this course for a few days now, and I cant seem to replicate what his code is doing. It doesn't create the \*.db file on my end. I even copied his code directly from his github and tried running, still really does not create the db file. When I run my [
main.py](http://main.py) file, it runs without any errors, just doesn't generate the db file. Any ideas? Here's the code.

**website/
main.py:**

from website import create
app

app = createapp()              # Initialize a flask application from init.py file

if name == 'main':      # Run this only when run directly from this file
   
app.run(debug=True)

**website/
init.py:**

from flask import Flask
from flask
sqlalchemy import SQLAlchemy
from os import path

# Initialze the db object
db = SQLAlchemy()      
DBNAME = 'database.db'

def create
app():
    app = Flask(name)

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