The Pocket Computer: How to Run Computational Workloads Without Cooking Your Phone
https://github.com/DaSettingsPNGN/S25_THERMAL-
I don't know about everyone else, but I didn't want to pay for a server, and didn't want to host one on my computer. I have a flagship phone; an S25+ with Snapdragon 8 and 12 GB RAM. It's ridiculous. I wanted to run intense computational coding on my phone, and didn't have a solution to keep my phone from overheating. So. I built one. This is non-rooted using sys-reads and Termux (found on F-Droid for sensor access) and Termux API (found on F-Droid), so you can keep your warranty. 🔥
What my project does: Monitors core temperatures using sys reads and Termux API. It models thermal activity using Newton's Law of Cooling to predict thermal events before they happen and prevent Samsung's aggressive performance throttling at 42° C.
Target audience: Developers who want to run an intensive server on an S25+ without rooting or melting their phone.
Comparison: I haven't seen other predictive thermal modeling used on a phone before. The hardware is concrete and physics can be very good at modeling phone behavior in relation to workload patterns. Samsung itself uses a reactive and throttling system rather than predicting thermal events. Heat is continuous and temperature isn't an isolated
/r/Python
https://redd.it/1p37186
https://github.com/DaSettingsPNGN/S25_THERMAL-
I don't know about everyone else, but I didn't want to pay for a server, and didn't want to host one on my computer. I have a flagship phone; an S25+ with Snapdragon 8 and 12 GB RAM. It's ridiculous. I wanted to run intense computational coding on my phone, and didn't have a solution to keep my phone from overheating. So. I built one. This is non-rooted using sys-reads and Termux (found on F-Droid for sensor access) and Termux API (found on F-Droid), so you can keep your warranty. 🔥
What my project does: Monitors core temperatures using sys reads and Termux API. It models thermal activity using Newton's Law of Cooling to predict thermal events before they happen and prevent Samsung's aggressive performance throttling at 42° C.
Target audience: Developers who want to run an intensive server on an S25+ without rooting or melting their phone.
Comparison: I haven't seen other predictive thermal modeling used on a phone before. The hardware is concrete and physics can be very good at modeling phone behavior in relation to workload patterns. Samsung itself uses a reactive and throttling system rather than predicting thermal events. Heat is continuous and temperature isn't an isolated
/r/Python
https://redd.it/1p37186
GitHub
GitHub - DaSettingsPNGN/S25_THERMAL-
Contribute to DaSettingsPNGN/S25_THERMAL- development by creating an account on GitHub.
Bobtail - A WSGI Application Framework
I'm just showcasing a project that I have been working on slowly for some time.
https://github.com/joegasewicz/bobtail
# What My Projects Does
It's called Bobtail & it's a WSGI application framework that is inspired by Spring Boot.
It isn't production ready but it is ready to try out & use for hobby projects (I actually now run this in production for a few of my own projects).
# Target Audience
Anyone coming from the Java language or enterprise OOP environments.
# Comparison
Spring Boot obviously but also Tornado, which uses class based routes.
I would be grateful for your feedback, Thanks
#
/r/Python
https://redd.it/1p3c9gi
I'm just showcasing a project that I have been working on slowly for some time.
https://github.com/joegasewicz/bobtail
# What My Projects Does
It's called Bobtail & it's a WSGI application framework that is inspired by Spring Boot.
It isn't production ready but it is ready to try out & use for hobby projects (I actually now run this in production for a few of my own projects).
# Target Audience
Anyone coming from the Java language or enterprise OOP environments.
# Comparison
Spring Boot obviously but also Tornado, which uses class based routes.
I would be grateful for your feedback, Thanks
#
/r/Python
https://redd.it/1p3c9gi
GitHub
GitHub - joegasewicz/bobtail: WSGI application framework
WSGI application framework. Contribute to joegasewicz/bobtail development by creating an account on GitHub.
What is the best Django course today (beginner → advanced)? Books, video, blog… anything.
I’m getting back into learning Django after stopping for a while, and I want to restart with modern learning resources that match the current real-world tech stack (Django 5.x, DRF, async, AI integration, modern tooling, etc.).
I’m looking for recommendations for the best learning path from beginner to advanced, including:
Online courses
YouTube tutorials
Books
Blogs/documentation
Project-based learning resources
Anything that helped you go from “I know nothing” to job-ready
Ideally, I want resources that focus on production-level skills, not just toy apps.
If you’ve learned Django recently (2023–2025), what resources made the biggest difference for you?
Thanks in advance!
/r/django
https://redd.it/1p2tgqx
I’m getting back into learning Django after stopping for a while, and I want to restart with modern learning resources that match the current real-world tech stack (Django 5.x, DRF, async, AI integration, modern tooling, etc.).
I’m looking for recommendations for the best learning path from beginner to advanced, including:
Online courses
YouTube tutorials
Books
Blogs/documentation
Project-based learning resources
Anything that helped you go from “I know nothing” to job-ready
Ideally, I want resources that focus on production-level skills, not just toy apps.
If you’ve learned Django recently (2023–2025), what resources made the biggest difference for you?
Thanks in advance!
/r/django
https://redd.it/1p2tgqx
Reddit
From the django community on Reddit
Explore this post and more from the django community
CAN SOME ONE EXPLAIN THIS?
https://programmers-haven.myshopify.com/
IM CONFUSED ABOUT WHAT THIS GUY IS TRYING TO SELL. IS THIS LEGIT?
/r/Python
https://redd.it/1p3ntd8
https://programmers-haven.myshopify.com/
IM CONFUSED ABOUT WHAT THIS GUY IS TRYING TO SELL. IS THIS LEGIT?
/r/Python
https://redd.it/1p3ntd8
Need help to make small changes
Can any good person help me with my class project? I will fail if i don't do it.need to get it done asaf I need to make some changes all instructions and how to do it are written. But still i don't know much code. The stack used is python flask.
About the software
It's a simple website which has login,admin,user, posting feature. The main goal is to make it free from any cyber vulnerability. Now the software has some vulnerability pointed out by another team. They have given us a report on it and what we should do. We need to make some changes implement 2-3 basic authentication features.
Please help 🙏😭
/r/flask
https://redd.it/1p3ga4p
Can any good person help me with my class project? I will fail if i don't do it.need to get it done asaf I need to make some changes all instructions and how to do it are written. But still i don't know much code. The stack used is python flask.
About the software
It's a simple website which has login,admin,user, posting feature. The main goal is to make it free from any cyber vulnerability. Now the software has some vulnerability pointed out by another team. They have given us a report on it and what we should do. We need to make some changes implement 2-3 basic authentication features.
Please help 🙏😭
/r/flask
https://redd.it/1p3ga4p
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Is there any way to simulate a slow network connection on localhost?
When I build a Flask app and test it on localhost, can I simulate a slow connection? (For example, by a python module that allows me to determine the speed of sending data from the Flask server)
/r/flask
https://redd.it/1p3pypy
When I build a Flask app and test it on localhost, can I simulate a slow connection? (For example, by a python module that allows me to determine the speed of sending data from the Flask server)
/r/flask
https://redd.it/1p3pypy
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Avenv - A Minimal Virtual Environment Script for Python
# What My Project Does
This is a minimal Linux-compatible script that streamlines Python virtual environment management. It creates each environment inside a dedicated directory in your home folder and sources the
Workflow example:
$ avenv -m newvenv
$ source avenv newvenv
# Target Audience
Developers who want a lightweight, zero-overhead method for managing Python virtual environments. Intended for personal workflows and simple development setups, not complex production pipelines.
# Comparison
Compared to tools like
# Background
I built this script for my own use several years ago, and it remains the most efficient workflow I’ve used for handling Python virtual environments.
Link: https://github.com/begbaj/avenv/
/r/Python
https://redd.it/1p3rxb6
# What My Project Does
This is a minimal Linux-compatible script that streamlines Python virtual environment management. It creates each environment inside a dedicated directory in your home folder and sources the
activate script directly. No wrappers, no frameworks, no extra abstractions.Workflow example:
$ avenv -m newvenv
$ source avenv newvenv
# Target Audience
Developers who want a lightweight, zero-overhead method for managing Python virtual environments. Intended for personal workflows and simple development setups, not complex production pipelines.
# Comparison
Compared to tools like
virtualenvwrapper, pipenv, or poetry, this script adds no metadata, no new workflow concepts, and no dependency management. It is a thin wrapper around python -m venv that provides a predictable, minimal interface focused solely on creating and activating environments.# Background
I built this script for my own use several years ago, and it remains the most efficient workflow I’ve used for handling Python virtual environments.
Link: https://github.com/begbaj/avenv/
/r/Python
https://redd.it/1p3rxb6
GitHub
GitHub - begbaj/avenv: A simple virtual environment manager for Bash
A simple virtual environment manager for Bash. Contribute to begbaj/avenv development by creating an account on GitHub.
I’m building a Python-native frontend framework that runs in the browser (Evolve)
I’m currently building a personal project called Evolve \- a Python-native frontend framework using WebAssembly and a minimal JavaScript kernel to manage DOM operations.
The idea: write UI logic in Python, run it in the browser, with a reactive system (no virtual DOM).
Still early stage, - I’ll be posting progress, architecture, and demos soon.
Would love to know: would you try a Python-first frontend framework?
/r/Python
https://redd.it/1p3p00u
I’m currently building a personal project called Evolve \- a Python-native frontend framework using WebAssembly and a minimal JavaScript kernel to manage DOM operations.
The idea: write UI logic in Python, run it in the browser, with a reactive system (no virtual DOM).
Still early stage, - I’ll be posting progress, architecture, and demos soon.
Would love to know: would you try a Python-first frontend framework?
/r/Python
https://redd.it/1p3p00u
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
If one python selling point is data-science and friends, why it discourages map and filter?
… and lambda functions have such a weird syntax and reduce is hidden in functools, etc.? Their usage is quite natural for people working with mathematics.
/r/Python
https://redd.it/1p3mjlc
… and lambda functions have such a weird syntax and reduce is hidden in functools, etc.? Their usage is quite natural for people working with mathematics.
/r/Python
https://redd.it/1p3mjlc
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
How do you implement customizable document templates (like QuickBooks)
I’m building an invoicing module in Django, and right now all my document templates (Quotation, POS Receipt, etc.) are hard-coded as Django HTML templates.
I want to redesign this so that:
- Multiple templates exist per document type
(e.g., Standard Invoice, Minimalist, POS Receipt, Japanese Style, etc.)
- Users can choose which template their organisation uses
(at setup time or inside settings)
- Users can customize parts of the template
(override header, colors, messages, table layout, footer text… basically inject custom HTML blocks)
- Ability to preview templates
(ideally show a small thumbnail preview)
/r/django
https://redd.it/1p43aga
I’m building an invoicing module in Django, and right now all my document templates (Quotation, POS Receipt, etc.) are hard-coded as Django HTML templates.
I want to redesign this so that:
- Multiple templates exist per document type
(e.g., Standard Invoice, Minimalist, POS Receipt, Japanese Style, etc.)
- Users can choose which template their organisation uses
(at setup time or inside settings)
- Users can customize parts of the template
(override header, colors, messages, table layout, footer text… basically inject custom HTML blocks)
- Ability to preview templates
(ideally show a small thumbnail preview)
/r/django
https://redd.it/1p43aga
Reddit
From the django community on Reddit
Explore this post and more from the django community
Onlymaps, a Python micro-ORM
Hello everyone! For the past two months I've been working on a Python micro-ORM, which I just published and I wanted to share with you: https://github.com/manoss96/onlymaps
Any questions/suggestions are welcome!
## What My Projects Does
A micro-ORM is a term used for libraries that do not provide the full set of features a typical ORM does, such as an OOP-based API, lazy loading, database migrations, etc... Instead, it lets you interact with a database via raw SQL, while it handles mapping the SQL query results to in-memory objects.
Onlymaps does just that by using Pydantic underneath. On top of that, it offers:
- A minimal API for both sync and async query execution.
- Support for all major relational databases.
- Thread-safe connections and connection pools.
## Target Audience
Anyone can use this library, be it for a simple Python script that only needs to fetch some rows from a database, or an ASGI webserver that needs an async connection pool to make multiple requests concurrently.
## Comparison
This project provides a simpler alternative to typical full-feature ORMs which seem to dominate the Python ORM landscape, such as SQLAlchemy and Django ORM.
/r/Python
https://redd.it/1p3us1n
Hello everyone! For the past two months I've been working on a Python micro-ORM, which I just published and I wanted to share with you: https://github.com/manoss96/onlymaps
Any questions/suggestions are welcome!
## What My Projects Does
A micro-ORM is a term used for libraries that do not provide the full set of features a typical ORM does, such as an OOP-based API, lazy loading, database migrations, etc... Instead, it lets you interact with a database via raw SQL, while it handles mapping the SQL query results to in-memory objects.
Onlymaps does just that by using Pydantic underneath. On top of that, it offers:
- A minimal API for both sync and async query execution.
- Support for all major relational databases.
- Thread-safe connections and connection pools.
## Target Audience
Anyone can use this library, be it for a simple Python script that only needs to fetch some rows from a database, or an ASGI webserver that needs an async connection pool to make multiple requests concurrently.
## Comparison
This project provides a simpler alternative to typical full-feature ORMs which seem to dominate the Python ORM landscape, such as SQLAlchemy and Django ORM.
/r/Python
https://redd.it/1p3us1n
GitHub
GitHub - manoss96/onlymaps: A Python micro-ORM
A Python micro-ORM. Contribute to manoss96/onlymaps development by creating an account on GitHub.
Python - Numerical Evidence - max PSLQ to 4000 Digits for Clay Millennium Problem (Hodge Conjecture)
* **What My Project Does**
The Zero-ology team recently tackled a high-precision computational challenge at the intersection of HPC, algorithmic engineering, and complex algebraic geometry. We developed the **Grand Constant Aggregator (GCA)** framework -- a fully reproducible computational tool designed to generate **numerical evidence** for the **Hodge Conjecture** on **K3 surfaces** ran in a Python script.
The core challenge is establishing formal certificates of numerical linear independence at an unprecedented scale. GCA systematically compares known transcendental periods against a canonically generated set of ρ real numbers, called the **Grand Constants**, for K3 surfaces of Picard rank ρ ∈ {1,10,16,18,20}.
The GCA Framework's core thesis is a computationally driven attempt to provide overwhelming numerical support for the Hodge Conjecture, specifically for five chosen families of K3 surfaces (Picard ranks 1, 10, 16, 18, 20).
The primary mechanism is a test for linear independence using the PSLQ algorithm.
The Target Relation: The standard Hodge Conjecture requires showing that the transcendental period $(\\omega)$ of a cycle is linearly dependent over $\\mathbb{Q}$ (rational numbers) on the periods of the *actual* algebraic cycles ($\\alpha\_j$).
The GCA Substitution: The framework substitutes the unknown periods of the algebraic cycles ($\\alpha\_j$) with a set of synthetically generated, highly-reproducible, transcendental numbers, called the **Grand Constants** ($\\mathcal{C}\_j$), produced by the **Grand Constant Aggregator (GCA)** formula.
The Test: The framework tests for an integer linear dependence
/r/Python
https://redd.it/1p44cr8
* **What My Project Does**
The Zero-ology team recently tackled a high-precision computational challenge at the intersection of HPC, algorithmic engineering, and complex algebraic geometry. We developed the **Grand Constant Aggregator (GCA)** framework -- a fully reproducible computational tool designed to generate **numerical evidence** for the **Hodge Conjecture** on **K3 surfaces** ran in a Python script.
The core challenge is establishing formal certificates of numerical linear independence at an unprecedented scale. GCA systematically compares known transcendental periods against a canonically generated set of ρ real numbers, called the **Grand Constants**, for K3 surfaces of Picard rank ρ ∈ {1,10,16,18,20}.
The GCA Framework's core thesis is a computationally driven attempt to provide overwhelming numerical support for the Hodge Conjecture, specifically for five chosen families of K3 surfaces (Picard ranks 1, 10, 16, 18, 20).
The primary mechanism is a test for linear independence using the PSLQ algorithm.
The Target Relation: The standard Hodge Conjecture requires showing that the transcendental period $(\\omega)$ of a cycle is linearly dependent over $\\mathbb{Q}$ (rational numbers) on the periods of the *actual* algebraic cycles ($\\alpha\_j$).
The GCA Substitution: The framework substitutes the unknown periods of the algebraic cycles ($\\alpha\_j$) with a set of synthetically generated, highly-reproducible, transcendental numbers, called the **Grand Constants** ($\\mathcal{C}\_j$), produced by the **Grand Constant Aggregator (GCA)** formula.
The Test: The framework tests for an integer linear dependence
/r/Python
https://redd.it/1p44cr8
Reddit
From the Python community on Reddit: Python - Numerical Evidence - max PSLQ to 4000 Digits for Clay Millennium Problem (Hodge Conjecture)
Explore this post and more from the Python community
Built free interview prep repo for AI agents, tool-calling and best production-grade practices
I spent the last few weeks building the tool-calling guide I couldn’t find anywhere: a full, working, production-oriented resource for tool-calling.
What’s inside:
66 agent interview questions with detailed answers
Security + production patterns (validation, sandboxing, retries, circuit breaker, cost tracking)
Complete MCP spec breakdown (practical, not theoretical)
Fully working MCP server (6 tools, resources, JSON-RPC over STDIO, clean architecture)
MCP vs UTCP with real examples (file server + weather API)
9 runnable Python examples (ReAct, planner-executor, multi-tool, streaming, error handling, metrics)
Everything compiles, everything runs, and it's all MIT licensed.
GitHub: https://github.com/edujuan/tool-calling-interview-prep
Hope you some of you find this as helpful as I have!
/r/Python
https://redd.it/1p469il
I spent the last few weeks building the tool-calling guide I couldn’t find anywhere: a full, working, production-oriented resource for tool-calling.
What’s inside:
66 agent interview questions with detailed answers
Security + production patterns (validation, sandboxing, retries, circuit breaker, cost tracking)
Complete MCP spec breakdown (practical, not theoretical)
Fully working MCP server (6 tools, resources, JSON-RPC over STDIO, clean architecture)
MCP vs UTCP with real examples (file server + weather API)
9 runnable Python examples (ReAct, planner-executor, multi-tool, streaming, error handling, metrics)
Everything compiles, everything runs, and it's all MIT licensed.
GitHub: https://github.com/edujuan/tool-calling-interview-prep
Hope you some of you find this as helpful as I have!
/r/Python
https://redd.it/1p469il
GitHub
GitHub - edujuan/tool-calling-interview-prep: Comprehensive interview prep guide to learn about Agents, AI and tool-calling
Comprehensive interview prep guide to learn about Agents, AI and tool-calling - edujuan/tool-calling-interview-prep
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/1p4851a
# 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/1p4851a
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
Why do devs prefer / use PyInstaller over Nuitka?
I've always wondered why people use PyInstaller over Nuitka?
I mean besides the fact that some old integrations rely on it, or that most tutorials mention PyInstaller; why is it still used?
For MOST use cases in Python; Nuitka would be better since it actually compiles code to raw machine (C) code instead of it being a glorified [.zip\] file and a Python interpreter in it.
Yet almost everyone uses PyInstaller, why?
Is it simplicity, laziness, or people who refuse to switch just because "it works"? Or does PyInstaller (same applies to cx_Freeze and py2exe) have an advantage compared to Nuitka?
At the end of the day you can use whatever you want; who am I to care for that? But I am curious why PyInstaller is still more used when there's (imo) a clearly better option on the table.
/r/Python
https://redd.it/1p46onk
I've always wondered why people use PyInstaller over Nuitka?
I mean besides the fact that some old integrations rely on it, or that most tutorials mention PyInstaller; why is it still used?
For MOST use cases in Python; Nuitka would be better since it actually compiles code to raw machine (C) code instead of it being a glorified [.zip\] file and a Python interpreter in it.
Yet almost everyone uses PyInstaller, why?
Is it simplicity, laziness, or people who refuse to switch just because "it works"? Or does PyInstaller (same applies to cx_Freeze and py2exe) have an advantage compared to Nuitka?
At the end of the day you can use whatever you want; who am I to care for that? But I am curious why PyInstaller is still more used when there's (imo) a clearly better option on the table.
/r/Python
https://redd.it/1p46onk
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
What could I have done better here?
Hi, I'm pretty new to Python, and actual scripting in general, and I just wanted to ask if I could have done anything better here. Any critiques?
import time
import colorama
from colorama import Fore, Style
color = 'WHITE'
colorvar2 = 'WHITE'
#Reset colors
print(Style.RESETALL)
#Get current directory (for debugging)
#print(os.getcwd())
#Startup message
print("Welcome to the ASCII art reader. Please set the path to your ASCII art below.")
#Bold text
print(Style.BRIGHT)
#User-defined file path
path = input(Fore.BLUE + 'Please input the file path to your ASCII art: ')
color = input('Please input your desired color (default: white): ' + Style.RESETALL)
#If no ASCII art path specified
if not path:
print(Fore.RED +
/r/Python
https://redd.it/1p4ffmh
Hi, I'm pretty new to Python, and actual scripting in general, and I just wanted to ask if I could have done anything better here. Any critiques?
import time
import colorama
from colorama import Fore, Style
color = 'WHITE'
colorvar2 = 'WHITE'
#Reset colors
print(Style.RESETALL)
#Get current directory (for debugging)
#print(os.getcwd())
#Startup message
print("Welcome to the ASCII art reader. Please set the path to your ASCII art below.")
#Bold text
print(Style.BRIGHT)
#User-defined file path
path = input(Fore.BLUE + 'Please input the file path to your ASCII art: ')
color = input('Please input your desired color (default: white): ' + Style.RESETALL)
#If no ASCII art path specified
if not path:
print(Fore.RED +
/r/Python
https://redd.it/1p4ffmh
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
Air gapped app
How does one prepare an air gapped app version of the Django project ?
are there tools to wrap frontend and backend in Docker and orchestrate this on a cloud ?
/r/django
https://redd.it/1p4fs71
How does one prepare an air gapped app version of the Django project ?
are there tools to wrap frontend and backend in Docker and orchestrate this on a cloud ?
/r/django
https://redd.it/1p4fs71
Reddit
From the django community on Reddit
Explore this post and more from the django community
Python Mutable Defaults or the Second Thing I Hate Most About Python
TLDR: Don’t use default values for your annotated class attributes unless you explicitly state they are a ClassVar so you know what you’re doing. Unless your working with Pydantic models. It creates deep copies of the models.
I also created a demo flake8 linter for it: https://github.com/akhal3d96/flake8-explicitclassvar/ Please check it out and let me know what you think.
I run into a very annoying bug and it turns out it was Python quirky way of defining instance and class variables in the class body. I documented these edge cases here: https://blog.ahmedayoub.com/posts/python-mutable-defaults/
But basically this sums it up:
class Members:
number: int = 0
class FooBar:
members: Members = Members()
A = FooBar()
B = FooBar()
A.members.number = 1
B.members.number = 2
# What you expect:
print(A.members.number) # 1
print(B.members.number) # 2
/r/Python
https://redd.it/1p469fk
TLDR: Don’t use default values for your annotated class attributes unless you explicitly state they are a ClassVar so you know what you’re doing. Unless your working with Pydantic models. It creates deep copies of the models.
I also created a demo flake8 linter for it: https://github.com/akhal3d96/flake8-explicitclassvar/ Please check it out and let me know what you think.
I run into a very annoying bug and it turns out it was Python quirky way of defining instance and class variables in the class body. I documented these edge cases here: https://blog.ahmedayoub.com/posts/python-mutable-defaults/
But basically this sums it up:
class Members:
number: int = 0
class FooBar:
members: Members = Members()
A = FooBar()
B = FooBar()
A.members.number = 1
B.members.number = 2
# What you expect:
print(A.members.number) # 1
print(B.members.number) # 2
/r/Python
https://redd.it/1p469fk
GitHub
GitHub - akhal3d96/flake8-explicitclassvar
Contribute to akhal3d96/flake8-explicitclassvar development by creating an account on GitHub.
The Labyrinth of Tech Careers: The Significance of Your Developer Portal
https://mappen.ai/blog/the-labyrinth-of-tech-careers-the-significance-of-your-developer-portal
/r/django
https://redd.it/1p4jg3x
https://mappen.ai/blog/the-labyrinth-of-tech-careers-the-significance-of-your-developer-portal
/r/django
https://redd.it/1p4jg3x