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
Do you use runtime type checking in Python?

Recently, I was surprised to see the following output from a Python program that uses type annotations:

> tail -3 unnacceptable.py
a: int = f()
b: int = g()
print(f'{a} + {b} = {a + b}')

> mypy --strict unnacceptable.py
Success: no issues found in 1 source file

> pyright unnacceptable.py
0 errors, 0 warnings, 0 informations

> python unnacceptable.py
1 + 2 = 12

The cause of this behaviour is the Any type:

def f() -> Any:
return '1'

def g() -> Any:
return '2'

Of course, the static type checkers have to allow the conversion from Any to int at compile-time (because the return values of f and g could indeed be ints), and they don't do anything to check the types of those return values at runtime.

This is in contrast to a statically-typed language (e.g. C# or Dart) which have a type equivalent to Python's Any (named dynamic), but

/r/Python
https://redd.it/1j318u1
Is flask with react ideal for a startup mvp?

Find Flask to be a bit more simplistic than Django or FastAPI. Want to use to it to build CRUD web app.

/r/flask
https://redd.it/1j3353q
Where to put custom form attributes that are not fields?

If I have a ModelForm with some fields and want to add an attribute to it that's not a field, should I put it in the "Meta" inner-class or should I put it directly inside the ModelForm class itself, so right beside the other fields?

In the same way, is an ok thing to do to add an inner Meta class to forms that are not ModelForms when I want to add attributes to them that are not fields?

/r/django
https://redd.it/1j34pfq
I Got Tired of "AI Shorts" Scams - So I Built My Own Free & Local Shorts Creator Tool!🎬

I love watching YouTube Shorts. What I don’t love? Seeing a flood of YouTubers claiming,
*"You can make easy AI Shorts in seconds!"* or "*Create your own automated YouTube channel*", .etc

Just to sell you their overpriced AI tools, subscriptions, or video editors.

So, out of sheer spite, I built [ShortsMaker](https://github.com/rajathjn/shorts_maker) \- a completely **free, open-source, local** Shorts automation tool that doesn’t try to upsell you anything. No subscriptions, no cloud nonsense - just Python, AI, and automation running entirely on your machine.

# What My Project Does

[ShortsMaker](https://github.com/rajathjn/shorts_maker) is a Python package that automates the creation of YouTube Shorts - entirely on your local machine. No cloud-based services, no subscriptions, no hidden paywalls, fully customizable short-video generation.

# ShortsMaker is built around four core classes:

* **ShortsMaker** – Handles multiple tasks, such as fetching posts from subreddits, generating audio, transcribing audio, and even fixing spelling & grammar in scripts.
* **MoviepyCreateVideo** – The engine that creates the short video by combining video clips, music, audio, and transcripts.
* **AskLLM** – Uses an AI LLM to extract the best possible **title, description, tags, and thumbnail description** for your script.
* **GenerateImage** – Uses FLUX to generate high-quality AI images for your Shorts.

# Target Audience

This project is for:

*

/r/Python
https://redd.it/1j36d7a
Made a Tool That Tracks & Downloads Every Song you Hear

I’m excited to share a project I’ve been working on called MusicCollector! It’s a Python based tool that helps you identify, track, and even download songs you listen to in real-time. Whether you’re a music enthusiast, a developer, or just someone who loves automating cool stuff, this might be right up your alley!

Have you ever heard a song while scrolling through Instagram, YouTube, or while traveling, only for it to get stuck in your head, but you completely forget what it was later?

I found myself in this situation way too often, whether I was in a cafe, walking through a city, or just mindlessly scrolling instagram/yt late at night. I'd hear a song, love it, but then totally forget what it was called when I wanted to find it again.

I wanted a tool that could passively listen while I go about my day, automatically recognize songs, and store them in a history that I could check later, complete with a downloaded copy so I wouldn’t have to search again to download it. Over time, I realized this could also act as a musical memory log, a collection of every track I’ve discovered, tied to different moments and places in my life.

Eventually, I even thought about adding a geolocation

/r/Python
https://redd.it/1j38x4r
What is the best resource to learn Flask in 2025?

Most of the popular tutorials are 4 or 5 years old now, should i follow Corey Scafer?



/r/flask
https://redd.it/1j3c3zs
Session cookies over HTTP

I have a misunderstanding over the "SESSION_COOKIE_SECURE" flask config element. If I understand correctly, it is supposed to ensure cookies are only sent over HTTPS. However, when I run my flask app in HTTP (unsecure), my session cookies are still sent to my browser and maked as "Secure: true".

What am I not understanding here?

/r/flask
https://redd.it/1j2xfle
Hot to have pretty frontend w/o Vue/react separate frontend. Just using Django itself.

Hi, pretty much everything in title. I wonder if it's possible to have modern and good looking frontend with just Django. Using htmx? I don't want to add another level of complication to my work but all my Django systems (I've developed few of them) look ugly like a old woman without teeth. It works but look like yahoo from 90'. I use crispy form, bootstrap and some custom .js but maybe someone could give a hint to a single hobby developer.

/r/django
https://redd.it/1j3bvda
Why can't I access "Meta" inner class of model?

class MyObjects(models.Model):
field1 = models.CharField(max_length=20)

class Meta:
verbose_name_plural = "MyObjects"

With a model like the one above, why is it then impossible for me to do something like this in a view let's say:

from app.models import MyObjects
print(MyObjects.Meta.verbose_name_plural)

/r/django
https://redd.it/1j3mxoz
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/1j3plxg
OpenArc v1.0.1: openai endpoints, gradio dashboard, faster inference on intel CPUs, GPUs and NPUs

Hello!

My project, OpenArc, is an inference engine built with OpenVINO for leveraging hardware acceleration on Intel CPUs, GPUs and NPUs. Users can expect similar workflows to what's possible with Ollama, LM-Studio, Jan, OpenRouter, including a built in gradio chat, management dashboard and tools for working with Intel devices.

OpenArc is one of the first FOSS projects to offer a model agnostic serving engine taking full advantage of the OpenVINO runtime available from Transformers. Many other projects have support for OpenVINO as an extension but OpenArc features detailed documentation, GUI tools and discussion. Infer at the edge with text-based large language models with openai compatible endpoints tested with Gradio, OpenWebUI and SillyTavern. 

Vision support is coming soon.

Since launch community support has been overwhelming; I even have a funding opportunity for OpenArc! For my first project that's pretty cool.

One thing we talked about was that OpenArc needs contributors who are excited about inference and getting good performance from their Intel devices.

Here's the ripcord:

An official Discord!
- Best way to reach me.
- If you are interested in contributing join the Discord!

Discussions on GitHub for:

Linux Drivers

Windows Drivers

Environment Setup

Instructions and models for testing out text generation for NPU devices!

A sister repo, OpenArcProjects!
- Share the things you build

/r/Python
https://redd.it/1j3rmo5
Created Code that Converts 3D Pose Outputs from Body Space to World Space

# What My Project Does

Uses 2D and 3D pose outputs from models such as mediapipe’s pose model and converts the 3D pose outputs that are in body space to world space. (Changes the origin of the coordinate system of the pose results from the hips of the body to the camera) This makes the pose results much more useful as it gives the motion of the entire body instead of just individual parts of the body relative to the hips. (Pose results of a belly flop might show little to no change, but when plotted in world space, you would be able to see a clear change in velocity in the body)

# Target Audience

People that want to convert pose model outputs from body space to world space.

# Comparison

To my knowledge, there aren’t really any other solutions to this problem.

# Other Details

More details on my blog: https://matthew-bird.com/blogs/Hip-to-Camera-Space.html

GitHub Repo: https://github.com/mbird1258/3D-Pose-Camera-to-Hip-Space

/r/Python
https://redd.it/1j3x6u4
Changing Model of CreateView and form

Hi all, I'd like to be able to have one CreateView that can work for a handful of models I have. Based on this portion of the documentation:

"These generic views will automatically create a `ModelForm`, so long as they can work out which model class to use"

I believe if I pass the right model to a class inheriting CreateView, I'll get a form to use for that model. With this in mind, is it possible to change the model a view references when requested? According to the documentation, I should be able to use get_object() or get the queryset, but both of those take me to SingleObjectMixin, which I don't think is used in CreateView. Am I attempting something impossible, or am I missing a key detail?

/r/django
https://redd.it/1j3hnxi
I use railway it's response time little slow.(over 1second)

First time, I thought it is related to plan.

So I upgrade free tier to hobby plan.

But the response time is same as before.

So I am considering to change the hosting server.

Could you guys recommend to me to deploy django app easily for MVP Testing?

I usually used aws, but Deployment process was not really good to me.

Railway made me feel deployment more easy.

Is there any service give me better performance than railway?

Specially, most of users will be located in south korea(East Asia)

PS. I already test setting location asis in railway, But the problem was same.

/r/django
https://redd.it/1j32mk5
PAR Infinite Minesweeper TUI v0.3.0 released

# What My project Does:

Play a game of minesweeper with infinite board size in your terminal!

# Whats New:

# v0.3.0

Internet leaderboard
Bug fixes

# v0.2.10

Update package metadata

# v0.2.9

Initial Release

# Key Features:

Infinite board size
Local high scores
Internet high scores
Auto saves and can be resumed

# GitHub and PyPI

Check out the project on GitHub or for full documentation, installation instructions, and to contribute: [https://github.com/paulrobello/par\_infini\_sweeper](https://github.com/paulrobello/par_infini_sweeper)
PyPI https://pypi.org/project/par\_infini\_sweeper/

# Comparison:

While there are a few minesweeper TUIs out there I have not found any infinite board versions.

# Target Audience

Anybody that loves minesweeper and terminals

/r/Python
https://redd.it/1j3vclw
Andrew Barto and Richard Sutton are the recipients of the 2024 ACM A.M. Turing Award for developing the conceptual and algorithmic foundations of reinforcement learning.
https://awards.acm.org/about/2024-turing

/r/MachineLearning
https://redd.it/1j42icj
Petition to rename Python 3.14 to Pithon!

# Is this a dumb joke? Yes. Is this the only shot we'll have at a joke like this? Yes. And is this a great way to celebrate what Pi's done for us Python developers? Totally.

I mean Python is heavily built around the magic number we know as 3.14, from games, charts and music, to even just screwing around with arithmetic functions! So why not appreciate pi's work with a special Python version?

The petition can be found here:
https://www.change.org/p/rename-python-3-14-to-pithon

# Edit: yeah, renaming it just for v3.14 is probably a bad thought, but i mean it would still be funny as a nickname!

/r/Python
https://redd.it/1j43aar
The features of Python's h*lp() function

Note: I censored the word "help" b/c it's not allowed in titles, but this blog post is about the function help(), not asking for help.

[https://www.pythonmorsels.com/help-features/](https://www.pythonmorsels.com/help-features/)

I almost always just append \`?\` to things in the REPL so I did not know that \`help()\` accepted string representations of objects, which will save me the work of instantiating an object just to get access to its method to ask for help:

>>> help("math.prod")
Help on built-in function prod in math:

math.prod = prod(iterable, /, *, start=1)
Calculate the product of all the elements in the input iterable.
>>> help("math.prod")
Help on built-in function prod in math:

math.prod = prod(iterable, /, *, start=1)
...


Even works for symbols:

>>> help("**")
The power operator
******************

The power operator binds more tightly than unary operators on its
left; it binds less tightly than unary operators on

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