/r/Python
If you have questions or are new to Python use r/LearnPython
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
Online Resources
Five life jackets to throw to the new coder (things to do after getting a handle on python)
PyMotW: Python Module of the Week
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
/r/Python
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.
Let's help each other learn Python! 🌟
https://www.python.org/downloads/release/python-3132/
Python 3.13 is the newest major release of the Python programming language, and it contains many new features and optimizations compared to Python 3.12. 3.13.2 is the latest maintenance release, containing almost 250 bugfixes, build improvements and documentation changes since 3.13.1.
It does not list precisely what bugs were fixed. Does anyone have a list?
Source: https://github.com/plexe-ai/smolmodels
smolmodels
is an open-source Python library that generates ML models for specific tasks from natural language descriptions of the problem + minimal code. It combines graph search and LLM code generation to try to find and train as good a model as possible for the given problem.
Here’s a quick example:
import smolmodels as sm
# Step 1: define the model in terms of intent, schemas
model = sm.Model(
intent="predict the probability of heart attack based on given features",
input_schema={
"age": int,
"gender": int,
"cp": int,
...
},
output_schema={"probability": float}
)
# Step 2: build the model
model.build(dataset=df, provider="openai/gpt-4o")
# Step 3: make predictions using the model
prediction = model.predict({
"age": 61,
"gender": 1,
"cp": 3,
...
})
# Step 4: save the model for future use
sm.models.save_model(model, "heart_attack_model")
This is an early-stage open source project for the Python/SDE/ML community. It's not production-ready, but it's on PyPI and you can experiment with it.
I'm not aware of any other tool that does this. If you want to use ML for a feature in your app, your alternatives are to either train an ML model yourself, fine-tune a pre-trained model, or leverage LLMs as a general-purpose solution. One of the main issues with using LLMs at scale, particularly in a latency-sensitive applications, is that huge LLMs are fundamentally slower and more expensive than smaller, task-specific models. This is what we’re trying to address with smolmodels.
The library is under the Apache 2.0 licence, so feel free to use it however you'd like (or contribute - we'd love that).
Source: https://github.com/sausix/qtui2pyi
What My Project Does
This tool creates Python pyi files from Qt Designer ui files which finally hint IDEs and linters to correct types. This primarily allows IDEs to show you dropdowns and auto completion features on accessing QtWidgets and their properties.
Target Audience
Python Qt GUI developers who prefer loading Qt Designer ui files directly instead of compiling them into Python modules. Some reasons for that:
setupUi
and similar.Comparison
Found no similar or working solution. mypy's stubgen is broken and just outputs Incomplete
types: mypy #14673
Batteries included: Example Designer file and demo applications for PySide6 and PyQt6.
Source: https://github.com/gauge-sh/tach
Python allows you to import and use anything, anywhere. Over time, this results in modules that were intended to be separate getting tightly coupled together, and domain boundaries breaking down.
We experienced this first-hand at a unicorn startup, where the entire engineering team paused development for over a year in an attempt to split up tightly coupled packages into independent microservices. This ultimately failed, and resulted in the CTO getting fired.
This problem occurs because:
Attempts we've seen to fix this problem always came up short. A patchwork of solutions would attempt to solve this from different angles, such as developer education, CODEOWNERs, standard guides, refactors, and more. However, none of these addressed the root cause.
With Tach, you can:
tach mod
)tach sync
)tach check
)tach show
and tach report
)You can also enforce a public interface for each module, and deprecate dependencies over time.
Developers working on large Python monoliths
I'd love if you try it out on your project and let me know if you find it useful!
Motivation : I'm broke. I desperately need that $500k job. If you remember, there was that super viral tweet about someone landing a $500k job without an interview—just because they had a fully green GitHub commit history. That got me thinking.
Now, I’m a lazy guy, but I want that kind of money. Naturally, I checked the comments, and a bunch of people said, "Oh, you can just do this with a script." But guess what? No one actually shared one. That was disappointing.
So, I did what any self-respecting engineer would do—I built it myself. And because I’m such a generous person (debatable), I open-sourced it for everyone. Meet: The GitHub Auto-Committer
What does this project do?
This bot automatically commits to a private GitHub repo to keep your contribution graph fully green. It:
And boom—your GitHub profile now looks like you code 24/7.
How does it work?
Is it safe to provide me with your token?
Yes and no. Let’s be real—you shouldn’t trust a random stranger on the internet. But here’s what I do:
Bottom line: If you don’t trust me, fork the repo and run it yourself. That’s the beauty of open source.
Target Audience:
Comparison with other tools:
I don’t know of any other tools like this. Maybe people have written scripts, but did they actually share them? Nope.
Relevant Links
Github URL : The Github Auto Committer Bot
Deployed Application URL : The Lazy Man Github
PS : I know not my best work in terms of coding practices but I will refactor it slowly. Meanwhile do check it out and let me know your feedback on this.
Edit : I just want to add one thing—I’m well aware that doing this won’t land anyone a job. For me, it’s purely a fun project. So, I’d kindly ask those reading this not to take it too seriously.
Hi everyone,
We're a startup that's developing a library called Javonet, designed to help integrate different programming languages seamlessly. Recently, we experimented with integrating Python’s Folium into a Node.js project. Traditionally, Folium has been used in Python-only projects, but our goal is to break down language barriers and enable developers to leverage the best tools from multiple ecosystems so we thought that it might be quite interesting to try and implement it.
I wrote an article that walks through our experience, the challenges we encountered, and some of the benefits of this cross-language approach: Create Stunning Maps in Node.js by Integrating Python’s Folium with Javonet.
I’d love to hear if anyone else has tried similar integrations or if you have ideas on how to further bridge the gap between languages. Your feedback is really valuable as we continue developing our library!
Last week, I got tired of how clunky even basic image editing can be, so I built a little app called EasyEdit to fix that. It’s lightweight, open-source, and just makes things... easy. No bloat, no unnecessary steps—just open, edit, done.
✅ Local Processing – No need to upload images to random online services. Process everything on your machine.
✅ Sick of Slow, Overcomplicated Editors – Just needed something fast and simple.
✅ Customizable – Wanted something I could tweak and improve over time.
✅ Useful for Other Developers – Figured others might find it handy too!
Video : YouTube
Github : Github
Try it out : Streamlit App
Natural Language Image Processing – Just tell the app what you want, and intelligent AI agents translate your request into precise OpenCV/NumPy operations.
Version Control for Edits – Think Git for image editing – undo/redo and track all changes.
Interactive Interface – Real-time previews, side-by-side comparisons, and click-to-get precise coordinates for editing.
Multiple Export Formats – Download processed images in PNG, JPG, or PDF formats.
✅ Image Editing: Resize, blur, draw shapes, add text, and more.
✅ Image Analysis: Extract dimensions, pixel values, and other properties.
✅ Custom Operations: If OpenCV doesn’t support something (e.g., crop has no built-in function), you can define your own!
Obviously, the better the LLM model, the better the results—but it can still generate single-line OpenCV/NumPy functions for edits like crop, resize, draw circle, add text, etc.
Target audience:
* If you want an open-source app for quick resolution changes, cropping, annotating, and more, this is for you!
* It’s open-source, so if you wanna try it out (or help make it better), check out the repo: GitHub
Hello,
I'm building libraries (the previous one was similar to this) to get criticism to improve my code and logic because even as a professional developer, I've never had a senior engineer/dev. I took in some feedback from the previous library to make something potentially useful this time.
This is a pre-release, so there are some things I'm ironing out. Let me know what you guys think. Always looking for criticism.
Github: https://github.com/hotnsoursoup/elixirdb
Pypi: https://pypi.org/project/elixirdb/
What My Project Does: ElixirDB simplifies interaction with SQLAlchemy, providing streamlined database operations, enhanced configuration management, and improved developer experience.
Target Audience:
Anyone that wants to stand up a quick database connection or may want the flexibility of switching engines from a central class. Perhaps you don't like the way sqlalchemy binds engines.
Comparison: Not sure, I couldn't really find anything out there. I did try googling quite a bit and even asked 3 different AI models to find me one, but it didn't come up with anything. I'd love for any references.
direct
, session
and scoped_session
Basic Usage
from elixirdb import ElixirDB
try:
connection = ElixirDB(engine_key="mysql")
except FileNotFoundError:
print("No elixir.yaml file found.")
Sample yaml configuration for EngineManager
app:
defaults: # All engines adopt these as a base.
engine_options:
echo: False
pool_size: 20
max_overflow: 10
pool_recycle: 3600
engines:
dbkey1:
dialect: mysql
url: mysql+pymysql://user:password@localhost:3306/db1
default: true # Default engine if engine_key is not provided.
execution_options:
autocommit: True
isolation_level: READ_COMMITTED
preserve_rowcount: True
loggingdb:
dialect: postgres
url_params:
drivername: psycopg2
host: localhost
port: 5432
user: postgres
password: password
query:
schema: public
engine_options:
echo: True
pool_timeout: 30
hide_parameters: True
customerdb:
dialect: oracle
url: oracle+cx_oracle://user:password@localhost:1521/orcl
I'm trying to upskill my proficiency in Python to get better & skillful at coding, be able to solve more difficult Leetcode problems and be able to crack interviews. Other than very basic syntax of Python, I am not an expert in the language.
I have seen people suggest these 2 books. May I know what these 2 offer, and which one will better suit my intent, if I could only choose one of them? I am planning on taking CS50 then go with either of these books to build on top.
https://testandcode.com/episodes/pytest-mock
pytest-mock is currently the #3 pytest plugin.
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
Let's deepen our Python knowledge together. Happy coding! 🌟
https://blog.apify.com/tiktok-scraper-python/
Just found a tutorial scraping TikTok data using Python's Selenium library (before the ban kicks in, I guess)
This is my first published python package, so any tips or critiques are very much welcome.
https://github.com/prozn/gifpgn/
[%eval ...]
comments for each move - so the package also offers:[%eval ...]
comments.See demo GIFs in the github readme.
Other projects such as chess_gif
and pgn2gif
do not offer:
Engine analysis and the features that come along with it
Move arrows to easily see moves and checks
Decorations such as headers
I hope some of you find this useful or interesting.
We have a service that merges JSON configuration fragments and it was spending most of its time in reduce(jsonmerge.merge, list_of_json_objects)
so we let claude-3.5-sonnet
rewrite that in Rust and package it as a Python module (don't worry, it was code reviewed by Rust programmers!) which is many times faster.
https://pypi.org/project/json-multi-merge/
https://github.com/Media-Platforms/json-multi-merge
key!
- Replace value instead of mergingkey--
- Remove this key from the resultAnyone who wants to merge JSON objects fast.
It's not as flexible as jsonmerge
but it does let you control how values are merged by putting !
or --
after their keys.
Hi Pythnoista's!
I'm excited to share with you html-to-markdown.
This library started as a fork of markdownify - I used it when I wrote a webscaper and was frustrated with its lack of typing. I started off by adding a py.typed
file, but found myself rewriting the entire library to add typing and more extensive tests, switching from its class based approach to a lighter, functional codebase.
This library is a fork of markdownify, an excellent HTML to Markdown converter that laid the groundwork for this project. While markdownify remains a solid choice, this fork takes a different approach:
html-to-markdown vs markdownify:
Other alternatives:
from html_to_markdown import convert_to_markdown
markdown = convert_to_markdown('<b>Hello</b> <a href="https://reddit.com">Reddit</a>')
# Output: '**Hello** [Reddit](https://reddit.com)'
pip install html-to-markdown
Check out the GitHub repository for more details and examples. If you find this useful, a ⭐ would be greatly appreciated!
The library is MIT-licensed and open to contributions. Let me know if you have any questions or feedback!
You will build an AI Agent - Browser Price Matching Tool that uses browser automation and some clever skills to adjust your product prices based on real-time web searches data.
The tool takes your current product prices (think CSV) and finds similar products online (targeting Amazon for demo purposes). It then compares prices, allowing you to adjust your prices competitively. The magic happens in a multi-step pipeline:
Full code link: Full code
make_query.json
.select_product.json
.learn_skill.py
).learn_skill_select_best_product.py
)..env
file in your project directory with:OPENAI_API_KEY="sk-your_api_key_here"learn_skill.py
to generate make_query.json
.learn_skill_select_best_product.py
to generate select_product.json
.product_price_matching.py
. The script will load your product data (sample data is included for demo, but easy to swap with your CSV), generate search queries, run browser agents asynchronously, scrape and parse the data, then output the enriched product listings.You built this project to automate price matching—a huge pain point for anyone running an e-commerce business. The idea was to minimize the manual labor of checking competitor prices while integrating up-to-date market insights. Plus, it was a fun way to combine automation,skill training, and browser automation!
product_price_matching.py
to manage browser agent load.With existing approaches you need to manually write parsing loginc and data transformation logic - here ai does it for you.
If you like the tutorial - leave a star github
Hi. The question is: what calculation method is implemented in numpy.random.normal? I have a problem to describe it manualy. First part is a gaussian algoritm (probably), but what is next to draw numbers? Or maybe i am wrong and there is sth another algoritm?
Hey folks! 👋
I wanted to share the project I've been hacking on.
Python Code Runner is a free Chrome extension which lets you run Python instantly in your browser, with zero environment setup.
What My Project Does
Target Audience
No & low-coders, web scrapers, data scientists, Python learners, LLM users
Comparison
Technical Details
Found this cool Python WFP library that makes network filtering super easy
Just discovered PyWFP while looking for a way to handle Windows Filtering Platform in Python. It's pretty neat - lets you create network filters with really simple syntax, similar to Windivert if anyone's familiar with that.
Quick example of what you can do:
from pywfp import PyWFP
pywfp = PyWFP()
filter_string = "outbound and tcp and remoteaddr == 192.168.1.3 and tcp.dstport == 8123"
with pywfp.session():
pywfp.add_filter(filter_string, filter_name="My Filter")
The syntax is really straightforward - you can filter by:
* TCP/UDP/ICMP
* IP ranges
* Specific ports
* Inbound/outbound traffic
Been playing with it for a bit and it works great if you need to programmatically manage Windows network filters. Thought others might find it useful!
Link: Github
I've been working on a text-to-video model from scratch using PyTorch and wanted to share it with the community! This project is designed for those interested in diffusion models.
For students and researchers exploring generative AI.
While not aiming for state of the art results, this serves as a great way to understand the fundamentals of text-to-video models.
Code, documentation, and example can all be found on GitHub:
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.
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
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
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
Let's help each other grow. Happy coding! 🌟
Hey everyone! In the spirit of release early, release often, I wanted to post to Reddit and Hacker News (for the first time ever!) about an idea of mine. Okay, so it's not a very original idea. It is however a missing gap in the Python ecosystem for learning and introduction to the language.
Check out the Tour of Go if you're not familiar with this concept already. The general idea is an in-browser interactive learning playground. (An in-browser REPL, if you will).
It needs more slides, it needs bugfixes and improvements overall, but the basic concept is here. The sandbox was implemented using code from healeycodes.com and ChatGPT did much of the other initial heavy lifting for me (I am a backend engineer by trade, my front-end skills are extremely rusty.)
The code is here: https://github.com/jadedragon942/tour_of_python/
The website is here: www.tourofpython.net
Disclaimer: it is nothing too fancy.
My long-term lofty goal is to build this and hand it off to python.org if possible/feasible.
Contributors/volunteers/feedback/opinions are of course welcome!
Hey everyone! I’ve developed KEGOMODORO, an open-source productivity tool designed to enhance time management! It's a customizable Pomodoro and Stopwatch timer that anyone can personalize and extend to suit their needs.
KEGOMODORO allows users to manage their time effectively with Pomodoro and Stopwatch modes. It features an easy-to-use interface, supports quick note-taking, logs your work hours, and even shows a graph to track your productivity over time. It also comes with a Behelit Mode, inspired by Berserk, for a fun, thematic countdown timer.
KEGOMODORO differs from traditional Pomodoro timers in that it is highly customizable. You can change themes to fit your personal style, and the app offers a unique Berserk-themed Behelit Mode that is a fun twist on productivity tools. Additionally, its lightweight design makes it easier to use without extra dependencies, unlike many Pomodoro apps that can be bulky or require complex setups. Plus, it’s built in Python, so it’s simple to modify and extend, especially for Python developers!
KEGOMODORO allows you to easily create custom themes to suit your style. The main goal of the app is flexibility and personalization—below are just a few examples of how it can be customized.
Feel free to fork, modify, and contribute to the project! I built it in Python to make it accessible for anyone to understand and tweak as needed.
🔗 GitHub: https://github.com/Kagankakao/KEGOMODORO
If you're looking for a fun and efficient way to improve your time management and productivity, check it out! 🚀🔥 Fork it and contribute if you're interested!
I normally use trinket.io to embed Python 3 codes into my website but I recently discovered that it has a 60-second time limit for running code. Do you have any other online options similar to Trinket?
Recently I had the opportunity to talk about the FastAPI under the hood at PyCon APAC 2024. The title of the talk was “FastAPI Deconstructed: Anatomy of a Modern ASGI Framework”. Then, I thought why not have a written version of the talk. And, I have decided to write. Something like a blog post. So, here it is.
https://rafiqul.dev/blog/fastapi-deconstructed-anatomy-of-modern-asgi-framework
Python 3.13 introduces an experimental option to disable the Global Interpreter Lock (GIL), something the community has been discussing for years.
I wanted to see how much of a difference it actually makes, so I explored and ran benchmarks on CPU-intensive workloads, including:
🔍 Key takeaways from my benchmarks:
📖 I wrote a full blog post with my findings and detailed benchmarks: https://simonontech.hashnode.dev/exploring-python-313-hands-on-with-the-gil-disablement
What do you think? Will No-GIL Python change how we use Python for CPU-intensive and parallel tasks?
Hey devs! Sharing my first project - an AI-powered PDF Report Generator! 🐍📊
Please checkout GitHub Repo for Tutorial Video https://github.com/bobinsingh/PedroReports-LLM-Powered-Report-Tool
I recently switched my career from life sciences to coding, and I wanted to create something useful after learning. So I built a tool that generates professional data analysis PDF reports from any tabular dataset. You just need to input what you want to analyze, and it does the job for you. Thought you might find it interesting!
The workflow is simple: feed it your data, and it handles everything from visualization to creating a fully formatted report with AI-generated descriptions. No more manual report writing! 🎉
Check it out on Github! Happy to answer any questions.
Hey everyone!
I wanted to share a Python program I made fairly recently.
FFE is a TUI (Command Line) Tool to make it easier to share files with your friends without anyone else seeing them. Some features currently present are:
The target audience for FFE is.. anyone. FFE is built so it's easy to use, so everyone, even your grandma, can use it.
The only requirement is a Windows PC with Windows 7 or newer, and the huge amount of storage space that is ~70 MB (if you install the Visual C++ Redist, which isn't required on Windows 10 and above).
FFE is different to other encryption programs, because instead of just using a password to encrypt files, it uses a Key File that you send to anyone that should be able to access your files, and then you just send each other files as many times as you want!
Oh yeah, and FFE is completely open-source, so you can look at all the code directly on GitHub.
Visit the GitHub if you want to download it, or if you would like to contribute.
Built with Python 3.13+
Have fun encrypting!
Hey folks! 👋
I wanted to share a personal tool I built for my note-taking workflow that might be interesting for terminal enthusiasts and markdown lovers. It's called Pinkmess, and it's a CLI tool that helps manage collections of markdown notes with some neat AI features.
Pinkmess is a command-line tool that helps manage collections of markdown notes with AI capabilities. It:
This is explicitly a personal tool I built for my own note-taking workflow and for experimenting with AI-powered note organization. It's **not** intended for production use, but rather for:
Unlike full-featured PKM systems (Obsidian, Logseq, etc.), Pinkmess:
Install it from PyPI:
$ pip install pinkmess
Create and edit a note
$ pinkmess note create
$ pinkmess note edit
Generate AI metadata:
$ pinkmess note generate-metadata --key summary
$ pinkmess note generate-metadata --key tags
GitHub: https://github.com/leodiegues/pinkmess
Built with Python 3.10+ and Pydantic.
Looking forward to your feedback! 🌸
Happy note-taking! 🌸