The Wayback Machine - https://web.archive.org/web/20241208133610/https://www.reddit.com/r/Python/
Skip to main content

Get the Reddit app

Scan this QR code to download the app now
Or check it out in the app stores
r/Python icon
r/Python icon

r/Python

members
online


Python .gitignore • Python .gitignore
Resource

I'm sure a lot of you have done this:

  1. Start new project

  2. Need that generic Python .gitignore file on GitHub

  3. Google "python gitignore" (though you probably typed "gitingore")

  4. Click link and click raw

  5. Copy all and paste in your local .gitignore

And I'm sure a lot of you probably just use curl and have it memorized or have it in your shell history or something (fzf ftw). But I can't be bothered to learn curl properly, and I got tired of the manual steps, so I just created a function in my .zshrc file:

function pgi {
    curl -JL https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Python.gitignore -o .gitignore
}

So now I can just run pgi whenever I start a new project, and boom, precious seconds of my life saved.

That's it, that's all I have, thanks for reading. I'm sure some of you have ever better solutions, but that's mine.


Sunday Daily Thread: What's everyone working on this week?


How to learn Web development. • How to learn Web development.
Discussion

Web development is one of the best field in software development and also it is one of the best thing to learn as it has the most number of jobs.For learning web development firstly you have to learn three basic programming languages HTML CSS and JavaScript these are the three basic pillars of Web development. Give one week to HTML, give two weeks to CSS and give one month to JavaScript after that give one month to React JS and other libraries like Next JS and Mongo DB. After that you can learn React native that you can make mobile apps. And here you go. This complete course will require at least 3 months.

I hope this will help you.


Flet vs Streamlit PWA and conceptual questions • Flet vs Streamlit PWA and conceptual questions
Discussion

I'm new to flet, but I'm experienced Flutter developer plus I'm a Generative AI Engineer and worked with streamlit or Gradio. I have some conceptual questions.
Q1. If flet uses Flutter, then why does the flet Flutter plugin require a URL? Why cannot the flet UI "live" all together in Flutter?
Q2. Since there's a URL needed anyway, what's the advantage of using it vs for example having a Streamlit UI displayed in a PWA?
Q3. Let's say I develop a personal assistant in flet. Can the assistant access my location, heart rate, my camera (for multi-modal Gen AI), microphone and speakers (for voice assistant functionalities)?


Programming language for future. • Programming language for future.
Discussion

The future will be of AI. This field of Machine learning and AI will rise in the future more and more and it will destroy some of the fields like web development and many more. In future the fields of software like web development will go down and sectors like Machine learning and AI will rise. Only those web developer will remain who will use AI software like Chat GPT and do the work of 10 developers.


PyCon US 2025 Registration Opens • •Brand Affiliate PyCon US 2025 Registration Opens
Official Event

Howdy Pythonistas :)

PyCon US 2025 registration and Travel Grant applications are officially open!

Early bird tickets are available until the first 500 tickets are sold or until January 6, 2025 (whichever comes first). Register today to get your discounted tickets and help us spread the word!

P.S. You can also Submit a Talk for the next 2 weeks!


Saturday Daily Thread: Resource Request and Sharing! Daily Thread

How we made Celery tasks bulletproof • How we made Celery tasks bulletproof
Tutorial

Hey folks,

I just published a deep dive into how we handle task resilience at GitGuardian, where our Celery tasks scan GitHub PRs for secrets. Wanted to share some key learnings that might help others dealing with similar challenges.

Key takeaways:

  1. Don’t just blindly retry tasks. Each type of failure (transient, resource limits, race conditions, code bugs ) needs its own handling strategy.

  2. Crucial patterns we implemented:

    • Ensure tasks are idempotent (may not be straightforward,

    • Used autoretry_for with specific exceptions + backoff

    • Implemented acks_late for process interruption protection

    • Created separate queues for resource-heavy tasks

Watch out for:

  1. Never set task_retry_on_worker_lost=True (can cause infinite retries)

  2. With Redis, ensure tasks complete within visibility_timeout

  3. Different behavior between prefork vs thread/gevent models for OOM handling


For those interested in the technical details: https://blog.gitguardian.com/celery-tasks-retries-errors/

What resilience patterns have you found effective in your Celery deployments? Any war stories about tasks going wrong in production?


VCAT: Video Transcriber and Translator • VCAT: Video Transcriber and Translator
Showcase

Have you ever wanted to share videos to your non bilingual friends? 🌎

Fear not because I (Claude) have made a script that does exactly that!

What My Project Does ⚡

Type in a video URL along with the target language and the program will:

A) Download the media from the URL (Uses youtube-dlp so most websites are compatible)
B) Transcribe it (srt file output)
C) Translate it (srt file output)
D) Add subtitles using ffmpeg

All fully automated of course!

🔍 https://github.com/tikene/video-caption-and-translate - You can see some sample translations on my repo to get an idea of how the output video looks

Target Audience 👥

If you have any friends who, for example, aren't fluent with English, you may have ran into some frustration when trying to share movies, videos or shows that you like. That's what motivated me to make this script, making it so you can easily share your interests and build human connections regardless of the language barrier (It's all about making the world a better place 💁‍♀️)

Comparison 🔄

The projects I could find relating to this subject either:

  • Don't accept URLs

  • Don't work with long videos

  • Don't add the subtitles directly to the video

  • Are outdated

Extra details 💡

The process is fully automatic so I actually find myself using it often, it only takes 10 seconds to start the translation.

Every language is supported because it uses OpenAI for translation, which means you do need an API key but it only costs around $0.01 for every minute of video. I spent $5 and have been using this script for months.

Conclusion 🎯

This is my first time sharing a project, so feedback would be greatly appreciated, if this gets any traction whatsoever I'll continue updating it. Let me know if you have any questions or suggestions


pytest-fixture-forms - A new plugin to simplify testing parameter variations • pytest-fixture-forms - A new plugin to simplify testing parameter variations
Showcase

Hey Python testing enthusiasts! I'm excited to share a pytest plugin I've been working on that makes testing different parameter variations much cleaner and more maintainable.

What my project does

If you've ever found yourself writing lots of parametrized tests for different API inputs, credentials, or configuration combinations, you know it can get messy quickly. This plugin lets you organize these variations as fixture methods in a class, making your tests more structured and easier to maintain.

Here's a quick example:

class UserCredentials(FixtureForms):
    @pytest.fixture
    def valid_user(self):
        return {"username": "john_doe", "password": "secure123"}

    @pytest.fixture
    def invalid_password(self):
        return {"username": "john_doe", "password": "wrong"}

def test_login(user_credentials):
    response = login_service.authenticate(**user_credentials.value)
    if user_credentials.form == "valid_user":
        assert response.status_code == 200
    else:
        assert response.status_code == 401

Key Features:

  • Auto-generates fixtures from class methods

  • Integrates with pytest's parametrization

  • Handles nested dependencies elegantly

  • Zero configuration needed

Target Audience

anyone want to write and maintain tests for combinations of parameter. it should be stable but hey! its a new project so expect rough edges.

Comparison 

there is no currently plugin in pytest that let you dynamically generate fixtures and test nodes in similar way to how pytest-fixture-forms does. this plugin is also being actively used inside a real product(actually this plugin was written as inside an internal tool testing code and later migrated by me to become a standalone pytest plugin).

Source

Check it out on GitHub or install with pip install pytest-fixture-forms.

I'd love to hear your thoughts and feedback!


ML Trading Bot that uses Ranked Ensemble Learning • ML Trading Bot that uses Ranked Ensemble Learning
Showcase

I created a ML Trading Bot - trained it for a little over 3 years with 24 years of data and started it live on November 20, 2024. It's been going over a little more than 2 weeks, but it's been doing great so far - not indicative of how it will perform but it's had a great debut if you can say that.

GitHub Repo: https://github.com/yeonholee50/AmpyFin

Bot Website: https://ampyfin-website.onrender.com/

What My Project Does

In essence, the trading bot ranks the strategies and gives them weights based on their overall performance while giving slight bias to recent performance (this is so it is reactive to current market trends and adjusts accordingly). These weights determine how much influence they have on the trading strategy. That's the oversimplified explanation of how the bot works. A more descriptive explanation is done on the website as well as README

Target Audience

Reason why I'm posting here is because I'm currently looking for contributors who have some expertise in Python (maybe want to contribute or just interested) on the trading strategies side. The more trading and diverse strategies there are, the better the bot will perform. This project is aimed towards developers interested in contributing or just anyone interested in the project. Currently there is 60 strategies, but the aim is to get much more: at least 100. If you have any questions on how it works or just interested in contributing, please don't hesitate to dm or comment.

Comparison

Most trading bots either use one strategy or multiple combination of strategies. The one's that use ML are too complex to understand or use libraries with jargons that are too coated. I specifically used ranked ensemble learning because it's something I've used in the past (for a facial feature measurement application for a medical company), but also because it's quite simple to understand and effective at the same time.


Accenture interview experience 2024 | I got selected | I used to python to ace the coding round • Accenture interview experience 2024 | I got selected | I used to python to ace the coding round
Discussion

I am a computer science student and I have multiple offeres. I have recently attended accenture interview and got selected. I have made a video on my interview experience : https://youtu.be/bq3FrksBpwc?si=3tv_QZNOhy4yhRLy . I will share my amazon interview experience and other experiences (like Tredence) in the follow videos.



Python binary which runs everwhere • Python binary which runs everwhere
Tutorial

I wanted to share some insights about an interesting project called python-build-standalone that I've been exploring.

What is python-build-standalone?

The python-build-standalone project produces fully usable Python installations that include most extension modules from the standard library. The key feature here is that it minimizes runtime dependencies.

Why Use It?

  1. Portability: The distributions are designed to work on any system for the targeted architecture, making it easier to deploy Python applications in diverse environments.

  2. Customizability: Users can include build artifacts and rich metadata, which allows for downstream repackaging. This means you can create a custom Python distribution tailored to specific needs—great for embedding Python in larger binaries.

  3. Sister Project - PyOxy: For those interested in enhancing their Python interpreter with Rust code, there's a related project called PyOxy that builds on these standalone distributions to create single-file executables.

Getting Started

If you’re interested in trying out python-build-standalone, you can find the documentation here. The documentation provides detailed instructions on how to build your own standalone Python distributions and includes examples of how to customize your builds.

Use Cases

This tool is particularly beneficial for:

  • Developers who need to distribute applications without requiring users to install Python or additional libraries.

  • Projects that aim for a minimal footprint on user systems.

  • Scenarios where embedding Python within other applications is necessary.

Happy coding!

P.S :- (I am building Origins AI, If you are facing some hard tech issues or If you want to get a product built, DM me)


I made a generative ai project template (python, uv, pytest and more) • I made a generative ai project template (python, uv, pytest and more)
Resource

Hey everyone,

I’ve been working on a template to get started with a generative AI project !

I’ve created a Generative AI Project Template that’s loaded with tools and features to streamline your AI development. You can check it out here on GitHub.

🛠️ Key Features

Engineering tools:

• ✅ Package management: UV

• ✅ Code quality: Pre-commit hooks with Ruff & Detect-secrets

• ✅ Logging: Colorful logs with Loguru

• ✅ Unit tests: Pytest

• ✅ Dockerized: Dockerfile & docker-compose for your evaluation pipeline

• ✅ Make commands: Simplify your workflow (install, run, test)

AI tools:

• ✅ LLMs: Run locally (Ollama, Ollamazure) or in the cloud (OpenAI, Azure OpenAI)

• ✅ Information extraction & QA from documents

• ✅ Chat interface to test your system

• ✅ Async code for efficient AI workflows

• ✅ AI Evaluation Frameworks: Promptfoo, Ragas, and more

CI/CD & Maintenance tools:

• ✅ Pipelines: GitHub Actions (.github/workflows) & GitLab CI (.gitlab-ci.yml)

• ✅ Local CI/CD pipelines: Run GitHub Actions with act and GitLab CI with gitlab-ci-local

Documentation tools:

• ✅ Documentation website: MkDocs + mkdocs-material

• ✅ GitHub Pages deployment: Easy deployment with mkdocs gh-deploy

Any feedback, issues, or PRs are welcome!


Friday Daily Thread: r/Python Meta and Free-Talk Fridays • Friday Daily Thread: r/Python Meta and Free-Talk Fridays
Daily Thread

Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

How it Works:

  1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.

  2. Community Pulse: Discuss what you feel is working well or what could be improved in the r/python community.

  3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

Guidelines:

  • All topics should be related to Python or the r/python community.

  • Be respectful and follow Reddit's Code of Conduct.

Example Topics:

  1. New Python Release: What do you think about the new features in Python 3.11?

  2. Community Events: Any Python meetups or webinars coming up?

  3. Learning Resources: Found a great Python tutorial? Share it here!

  4. Job Market: How has Python impacted your career?

  5. Hot Takes: Got a controversial Python opinion? Let's hear it!

  6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟


Built a tool to step through LeetCode Python solutions—feedback welcome! 🐛✨ • Built a tool to step through LeetCode Python solutions—feedback welcome! 🐛✨
Showcase

Hey everyone! 👋

# What my project does

This tool allows you to step through Python code for LeetCode problems line-by-line. It highlights the current line being executed and shows the real-time values of variables and sub-expressions. It's designed to help visualize code execution and understand the logic flow more easily.

check it our : https://github.com/roshixyz/StepThrough

# Target Audience

anyone trying to understand code behaviour (specifically Leetcode problems)

# Comparison

Unlike standard IDEs or debuggers, this tool focuses on simplifying the debugging process for LeetCode-style coding challenges. It provides a clear, visual breakdown of what’s happening under the hood, making it easier to spot issues and understand how each line affects the program’s state.

Demo : https://x.com/roshi_xyz/status/1864257060042330455


HandiRokuRemote (Open Source) - Control your Roku with only your hand gestures • HandiRokuRemote (Open Source) - Control your Roku with only your hand gestures
Showcase

What My Project Does

This is a Python application that lets you control your Roku device with nothing but hand gestures! Using Mediapipe's Hand Landmark Detector, it tracks your hand, identifies gestures, and sends commands to your Roku via its External Control Protocol.

Check out the demo gif

Features:

*Real-time hand tracking: Gestures like "thumbs up" control volume or navigation.

*Cross-device support: Works with any Roku device on the same network.

*Easy setup: Plug in a camera, and you’re ready to go.

Target Audience

The target audience is anyone who's ever lost their TV remote, but probably more likely fellow tinkerers and anyone interested in computer-vision.

Comparison

As far as I can tell, there is no comparison. I've looked around and haven't found anything that does what this does. I guess the only comparison is a regular remote (but you lost that earlier, remember?)

Check out the code on Github

Or download the .exe and try it out! PC only - Download

Let me know what you think!


💥 Tech Talks Weekly #40: newly uploaded videos from PyCon AU 2024 • 💥 Tech Talks Weekly #40: newly uploaded videos from PyCon AU 2024
News

Hello again r/Python. I'm sharing an excerpt from the latest issue of Tech Talks Weekly with the newest PyCon AU 2024 talks, ordered by the view count for your convenience. Let me know what you think!

  1. ""Switching to MongoDB: The challenges of translating database schemas" - Katie Bell (Pycon AU 2024)" ⸱ +600 views ⸱ 28 Nov 2024 ⸱ 00h 29m 00s

  2. ""How we used Python to try and save lives" - Anthony Baxter (Pycon AU 2024)" ⸱ +300 views ⸱ 01 Dec 2024 ⸱ 00h 30m 56s

  3. ""Time and Time Again" - Yaakov (Pycon AU 2024)" ⸱ +300 views ⸱ 30 Nov 2024 ⸱ 00h 28m 10s

  4. ""Student showcase" - Education Track (Pycon AU 2024)" ⸱ +300 views ⸱ 29 Nov 2024 ⸱ 01h 40m 15s

  5. "Failsafes and Safety Fails: How to crash a train and other lessons for software engineers" ⸱ +200 views ⸱ 29 Nov 2024 ⸱ 00h 31m 03s

  6. "Space Django: Migrating and Redesigning a Database while Hunting for Satellites." ⸱ +200 views ⸱ 28 Nov 2024 ⸱ 00h 31m 16s

  7. "Where am I? What am I doing? Mobile App development in Python" ⸱ +200 views ⸱ 30 Nov 2024 ⸱ 00h 29m 38s

  8. "How to confirm that the index you added actually improves query performance" ⸱ +200 views ⸱ 01 Dec 2024 ⸱ 00h 28m 47s

  9. "ML ain’t your only hammer: adding mathematical optimisation to the data scientist’s toolbox" ⸱ +200 views ⸱ 01 Dec 2024 ⸱ 00h 19m 14s

  10. ""Quantifying Nebraska" - Adam Harvey (Pycon AU 2024)" ⸱ +100 views ⸱ 29 Nov 2024 ⸱ 00h 26m 06s

See the remaining list here: https://www.techtalksweekly.io/i/152513751/pycon-au


Is a TypeScript-like language for Python possible and desirable? • Is a TypeScript-like language for Python possible and desirable?
Discussion

While tools like MyPy, Pyright, and Pylance have significantly improved static typing in Python, they don't offer the same level of rigor and performance as fully compiled languages.

Imagine a language that compiles to Python bytecode, providing:

  • Strong static typing: catching errors early and improving code reliability.

  • Performance benefits: through compilation and optimizations.

  • Advanced language features: such as algebraic data types, pattern matching, and better concurrency support.

But what are the trade-offs? Would such a language be compatible with the vast Python ecosystem? Could a compiler achieve the same performance as the CPython interpreter? And would the added complexity outweigh the benefits for many Python developers?

I'm curious to hear your thoughts. Have you ever experimented with statically typed Python dialects or considered the potential benefits and drawbacks of a more rigid type system?


Agent-Based Modeling library Mesa releases version 3.1 • Agent-Based Modeling library Mesa releases version 3.1
News

Hi everyone! After our huge Mesa 3.0 release, we're proud to announce Mesa 3.1 less than a month later. It contains some major spatial improvements and groundwork for new control and data collection features.

What's Agent-Based Modeling?

Ever wondered how bird flocks organize themselves? Or how traffic jams form? Agent-based modeling (ABM) lets you simulate these complex systems by defining simple rules for individual "agents" (birds, cars, people, etc.) and then watching how they interact. Instead of writing equations to describe the whole system, you model each agent's behavior and let patterns emerge naturally through their interactions. It's particularly powerful for studying systems where individual decisions and interactions drive collective behavior.

What's Mesa?

Mesa is Python's leading framework for agent-based modeling, providing a comprehensive toolkit for creating, analyzing, and visualizing agent-based models. It combines Python's scientific stack (NumPy, pandas, Matplotlib) with specialized tools for handling spatial relationships, agent scheduling, and data collection. Whether you're studying epidemic spread, market dynamics, or ecological systems, Mesa provides the building blocks to create sophisticated simulations while keeping your code clean and maintainable.

What's new in Mesa 3.1?

This release adds experimental support for Observables and Computed, enabling a more reactive and responsive programming model for agent-based simulations. The new Observable and Computable classes allow developers to declaratively define attributes that automatically emit signals when their values change, and compute derived values that update dynamically. This lays the groundwork for more advanced event handling and data visualization features in future releases (#2291).

The experimental cell space module has been updated with full support for n-dimensional property layers. These allow agents to easily interact with and modify spatial properties of the environment, such as terrain, resources, or environmental conditions. The new implementation provides a more intuitive attribute-based API and ensures tight integration with the cell space architecture (#2512).

Mesa now includes built-in support for logging using the standard Python logging module. This provides developers with a flexible and powerful way to add structured diagnostic and debug output to their simulations, without the need for custom logging solutions. The logging system is integrated throughout the library, including the new SolaraViz visualization system (#2506).

Creating multiple agents with varying initialization parameters is now significantly easier with the new Agent.create_agents class method. This factory function supports both uniform and per-agent parameters, simplifying the code required to set up a simulation with a large number of heterogeneous agents (#2351).

In addition to the major new features, this release includes a number of smaller enhancements and bug fixes that improve the overall developer experience. These include removing deprecated functionality, cleaning up examples, and addressing various edge cases reported by the community. Mesa 3.1 requires Python 3.11 or higher.

Talk with us!

We always love to hear what you think:


Is a TypeScript-like language for Python possible and desirable? • Is a TypeScript-like language for Python possible and desirable?
Discussion

While tools like MyPy, Pyright, and Pylance have significantly improved static typing in Python, they don't offer the same level of rigor and performance as fully compiled languages.

Imagine a language that compiles to Python bytecode, providing:

  • Strong static typing: catching errors early and improving code reliability.

  • Performance benefits: through compilation and optimizations.

  • Advanced language features: such as algebraic data types, pattern matching, and better concurrency support.

But what are the trade-offs? Would such a language be compatible with the vast Python ecosystem? Could a compiler achieve the same performance as the CPython interpreter? And would the added complexity outweigh the benefits for many Python developers?

I'm curious to hear your thoughts. Have you ever experimented with statically typed Python dialects or considered the potential benefits and drawbacks of a more rigid type system?


ProgressPal (an alternative/iteration to tqdm) • ProgressPal (an alternative/iteration to tqdm)
Showcase

Get ProgressPal here is full documentation available in the Github repo: https://github.com/levi2234/Progresspal

What My Project Does The code progress tracker called ProgressPal provides an easy to use environment for tracking python functions, iterables and logs. It tries to keep the known tqdm syntax while expanding the usability for simulataneous python runtimes such as Threads and parallel processes. ProgressPal provides an easy to access online environment which collects all progress in one place, visible from anywhere in the world. The main features included are:

  • Progress Tracking: Track the progress of Python iterables, functions, and log messages in real-time.

  • Decentralized Monitoring: Monitor multiple Python scripts from any device with an internet connection.

  • Collaborative Projects: Collaborate and monitor the real-time progress of various scripts running on different devices and processes.

  • Distributed Systems: Track progress across distributed systems for seamless monitoring and remote collaboration.

  • Function Tracking: Track the call-count, execution time distribution, execution history, time between calls, error count, function file origin, and function name.

  • Iterable Tracking: Track the progress of iterables and generators with a progress bar. Additionally, track the total number of iterations, current iteration, and percentage completion, time remaining, iteration execution time, and iteration rate.

  • Log Server: Start a log server to receive progress updates from Python scripts. The log server can be accessed from any device with an internet connection.

  • Threading support: Track the progress of multiple threads and processes simultaneously.

  • Search Functionality: Search for specific functions and iterables in the log server.

Target Audience ProgressPal is made for people who are working with multiple python processes or want to remotely monitor their code. ProgressPal has collaboration in mind providing a 2 click monitoring server for everyone to use. Because of the 1 ms overhead (9ns of tqdm) of the code we recommend this for tracking longer execution times of loops and functions to minimize impact.

Comparison During my work I grew increasingly annoyed with having to jump from terminal to terminal using tqdm. I had a use for a central logging environment. Scouring through my options I couldn't find a suitable option. So after 2 years of being annoyed I decided to make my own.

Comments This project was my first experience with web developement (code quality does reflect this) Because this is my first webdev project security is not the first priority. Therefore this project is mainly developed for personal use and recommended not to run on critical systems. However, it is a great tool to use during developement which I myself have used this in projects with multiple dozens of simultaneous processes without problems.