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
Testing in Python Memes and wisdom request

Been working with data in python for several years, lately decided to dive deeper into OOP to upgrade my code. Currently writing my first tests for my side project (just a python REST API wrapper), chose PyTest. Gents and Ladies, it is hard I can tell you.

I mean for the simple classes it was fun, but when I got to the Client class that is actually using all the others it got tricky. I had to mock

Request module, so I can expect the request without it actually been sent.
The config class that "have" the api key
The factory that instantiates Pydantic models used to build the request
The models said factory "returns"
The model used to validate the response
Obviously the response.

Despite me believing my code is neat and decoupled, just when I got to write the test I realized how much coupled it actually is. Thank god for the ability to mock, so I can "create" only the parts of classes the tested method is using. Also, got me to realize that a method of 20 lines uses so much and does so much, I am partly proud, partly frustrated.

Anyway, I am mainly writing for some

/r/Python
https://redd.it/1kukqdy
Jinja UI components

There are multiple UI components for JS frameworks and libraries. Just to mention a few:-
- shadcn UI
- materialize etc

Is there any for flask(Jinja templates)?

## Context
I see JS components that I really like and would love to use them in my frontend(Jinja templates) but I always mostly have to implement them on my own.

/r/flask
https://redd.it/1kujybr
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/1kupen2
Out of the box DJango CMS options in 2025?

Coming back to Django after a long while.

What are the options in 2025 for a ready to go out of the box CMS using django that i can extend easily enough when i need to .

Previously liked Wagtail but i want to get up and running quick without getting involved with set up from the start. also previously tried codered cms which i liked too for a more baked solution.

/r/django
https://redd.it/1kuobtm
Flask_AppBuilder / Flask-Admin future, or alternatives?

A few years ago I used Flask-AppBuilder to rapidly build and roll-out an internal corporate web app and it saved us a lot of time. Now we're about to upgrade the app, and we're questioning if we should stick with FAB due to it feeling like it's in maintenance mode and steadily falling behind. While some small update releases are still made, efforts to make major updates like Flask 3, SQLAdmin 2, Bootstrap 5, etc seem to have stalled.

Looking at Flask-Admin, it hasn't seen a release since 2023, and other than a brief bust of v2 alphas a few months back appears even less active.

Neither option seems one to stick with for a potential 3-5 year support cycle, unless anyone knows of their future plans? I'm not aware of any viable alternatives either? We could always DIY the parts that we use, but I'd rather avoid the extra dev effort and ongoing maintenance.

/r/flask
https://redd.it/1kuhtos
Has anyone worked with a proprietary python web framework before? How common is it?

At my current job we have a really weird proprietary python web framework for some of our applications and i feel like future employers are not going to believe me when i say it.

/r/Python
https://redd.it/1kunsod
Allow user to choose file/dir

Hey all, trying to create a simple form using form.Forms and trying to add a field that allows users to browse their pc and either give a file or a folder/dir

I just can't find a way to allow both in a single selection field.

I can make a user select a file using forms.FileField() however this doesn't allow a folder to be selected.

Other ways i know, are inputting a directory field in html that uses webkitdirectory, but as far as im aware, this would mean i have to split file/folder inputs. Which would make the rest of the logic annoying (should only input one.)

I know there must be a simple way to browse a directory, but i just can't find one. Does anyone have ideas?

/r/djangolearning
https://redd.it/1kusrcd
Things to learn in django after basics

I am new to django . I have learn the basic and also made some small project . How should I improve my django skills more . What are the things or tool which I might have missed in basic and are required.
Please suggest me

/r/django
https://redd.it/1kutgxw
[R] We taught generative models to segment ONLY furniture and cars, but they somehow generalized to basically everything else....

/r/MachineLearning
https://redd.it/1kuq3h0
Dedent multiline string literal (a.k.a. triple quoted string literal)

Dedenting multiline string literal is discussed (again).

A poll of ideas is being run before the PEP is written.
If you're interested in this area, please read the thread and vote.

Poll: https://discuss.python.org/t/pre-pep-d-string-dedented-multiline-strings-with-optional-language-hinting/90988/54

Ideas:

1. Add str.dedent() method that same to textwrap.dedent() and do not modify syntax at all. It doesn't work nicely with f-string, and doesn't work with t-string at all.
2. Add d-string prefix (d"""). It increase combination of string prefixes and language complexity forever.
3. Add from __future__ import. It will introduce breaking change in the future. But transition can be helped by tools like 2to3 or pyupgrade.

/r/Python
https://redd.it/1kuuzqn
Best Cloud Storage for Managing and Editing Word, Excel, and PDF Documents in a Python Web App?

Hi all,

I'm building a document upload system in Python for my web app where users can upload, view, and edit documents like Word, Excel, and PDF files.

I’m trying to decide which cloud storage solution would be best for this — AWS S3, Azure Blob Storage, Google Cloud Storage, or something else?

Also, what technologies or libraries would you recommend for viewing and editing these document types directly in the app?

Thanks in advance for your suggestions!

/r/Python
https://redd.it/1ku8enh
Python cant wont play the sound file

So I just got to coding as a hobby for now, I was trying to make a file, app or whatever, that makes a funny sound when you open it and the window says "get trolled bozo"

So basically, It opens the window and says the text. But the sound isnt coming through. I also asked GPT he said that it could be somewhere else. But I set the path to where the code and sound is. Honestly I have no clue anymore but still would love to hear what went wrong and how to fix it.

This was my first code in like 5years. I made one before, a traffic light on a breadboard. But that story can wait for another time.

/r/Python
https://redd.it/1kuwwmu
🧠 Visualizing Python's Data Model: References, Mutability, and Copying Made Clear

Many Python beginners (and even experienced devs) struggle with concepts like:

* references vs. values
* mutable vs. immutable data types
* shallow vs. deep copies
* variables pointing to the same object across function calls
* recursion and the call stack

To write bug-free code, it's essential to develop the right **mental model** of how Python actually handles data and memory. Visualization can help a lot with that.

I've created a tool called [`memory_graph`](https://pypi.org/project/memory-graph/), a teaching tool and debugger aid that generates **visual graphs of Python data structures** — including shared references, nested structures, and the full call stack.

It helps answer questions like:

* “Does this variable point to the same list as that one?”
* “What part of this object is actually copied?”
* “What does the stack look like in this recursive call?”

You can generate a memory graph with a single line of code:

import memory_graph as mg
a = [4, 3, 2]
b = a
mg.show(mg.stack()) # show graph of the call stack

It also integrates with **debuggers** and **IDEs** like VSCode, Cursor AI, and PyCharm for real-time visualization while stepping through code.

Would love feedback from Python educators, learners, and tooling enthusiasts.

/r/Python
https://redd.it/1kv2y0n
Have we all been "free handing" memory management? Really?

This isn't a question so much as it's a realization on my part. I've recently started looking into what I feel like are "advanced" software engineering concepts. Right now I'm working on fine grain runtime analysis, and memory management on particular.

I've started becoming acquainted with pyroscope, which is great and I highly recommend it. But pyroscope doesn't come with memory management for python. Which is surprising to me given how popular python is. So I look into how folks do memory analysis in python. And the leading answer is memray, which is great and all. But memray was released in 2022.

What were we doing before that? Guesswork and vibes? Really? That's what I was doing, but what about the rest of y'all? I've been at this for a decade, and it's shocking to me that I haven't come across this problem space prior. Particularly since langagues like Go / Rust / Java (lol) make memory management much more accessible to engineers.

Bonus: here's the memray and pyroscope folks collaborating: https://github.com/bloomberg/memray/issues/445

--- EDIT ---

Here is what I mean by freehanding memory management:

Imagine you are writing a python application which handles large amounts of data. This application was written by data scientists

/r/Python
https://redd.it/1kv2tm8
Consigli per imparare Python

Ciao! Ho un esame universitario su Python dove, per altro, sono stato già bocciato una volta. In statistica ho usato RStudio e ho avuto molte difficoltà con l’apprendimento, inoltre le slide della prof non sono molto esplicative…
Chiedo consigli validi su siti/video che offrano un corso (possibilmente gratuito) per imparare e passare questa idoneità.

/r/Python
https://redd.it/1kv92e9
Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas 💡

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

/r/Python
https://redd.it/1kvgq43
Just a reminder to never blindly trust a github repo

I recently found some obfuscated code.

heres forked repo https://github.com/beans-afk/python-keylogger/blob/main/README.md

For beginners:

\- Use trusted sources when installing python scripts


EDIT: If I wasnt clear, the forked repo still contains the malware. And as people have pointed out, in the words of u/neums08 the malware portion doesn't send the text that it logs to that server. It fetches a chunk of python code FROM that server and then blindly executes it, which is significantly worse.

/r/Python
https://redd.it/1kvdgqa
P I made a OSS alternative to Weights and Biases

Hey guys!

https://github.com/mlop-ai/mlop

I made a completely open sourced alternative to Weights and Biases with (insert cringe) blazingly fast performance (yes we use rust and clickhouse)

Weights and Biases is super unperformant, their logger blocks user code... logging should not be blocking, yet they got away with it. We do the right thing by being non blocking.

Would love any thoughts / feedbacks / roasts etc

/r/MachineLearning
https://redd.it/1kvdjet
P I scraped and applied to 7,932 Data Science jobs directly from corporate websites.


I realized many jobs on company career pages never appear on classic job boards, so I wrote a script that scrapes listings from 70k+ corporate.
Then I built a matching script that filters only the jobs most aligned with my CV.
Finally, I automated the application process with a script that applies to those jobs for me.
You can try it here: laboro.co


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