r/Python • • 20d ago

Showcase Showcase Thread

29 Upvotes

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.


r/Python • • 18h ago

Daily Thread Tuesday Daily Thread: Advanced questions

7 Upvotes

Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

How it Works:

  1. Ask Away: Post your advanced Python questions here.
  2. Expert Insights: Get answers from experienced developers.
  3. Resource Pool: Share or discover tutorials, articles, and tips.

Guidelines:

  • This thread is for advanced questions only. Beginner questions are welcome in our Daily Beginner Thread every Thursday.
  • Questions that are not advanced may be removed and redirected to the appropriate thread.

Recommended Resources:

Example Questions:

  1. How can you implement a custom memory allocator in Python?
  2. What are the best practices for optimizing Cython code for heavy numerical computations?
  3. How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?
  4. Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?
  5. How would you go about implementing a distributed task queue using Celery and RabbitMQ?
  6. What are some advanced use-cases for Python's decorators?
  7. How can you achieve real-time data streaming in Python with WebSockets?
  8. What are the performance implications of using native Python data structures vs NumPy arrays for large-scale data?
  9. Best practices for securing a Flask (or similar) REST API with OAuth 2.0?
  10. What are the best practices for using Python in a microservices architecture? (..and more generally, should I even use microservices?)

Let's deepen our Python knowledge together. Happy coding! 🌟


r/Python • • 1h ago

Discussion I've started treating the output of my little Python scripts as a user interface

23 Upvotes

I inherited a bunch of internal Python scripts at work last year. Most of them were perfectly readable, did their job and had been running for years without any major issues.

The annoying part was figuring out what they'd actually done.

One would print "Done" whether it processed 400 files or found nothing to process. Another would silently skip invalid records. To understand the result of a successful run I sometimes had to read the source code.

I've since developed a habit of ending even fairly trivial scripts with a small summary of what was found, what changed, what was skipped and why.

It's probably the smallest change I've made to my coding habits with the biggest practical payoff. Especially when revisiting something I wrote six months ago.

I think we spend a disproportionate amount of time making Python code pleasant for other developers to read compared to making Python programs pleasant for other people to actually run.


r/Python • • 12h ago

Discussion PyInstaller on Windows: does code signing stop Smart App Control blocking the DLLs?

29 Upvotes

I ship a desktop app with a python backend frozen with pyinstaller, currently unsigned. Two problems on Windows:

  • SmartScreen "Windows protected your PC" on every fresh download
  • worse: on some users' machines Smart App Control blocks the bundled .pyd/.dll files ("An Application Control policy has blocked this file") and the app just dies on startup

I'm about to pay for signing, and the part I can't find a straight answer on is the pyinstaller side:

  1. Is signing the main exe enough, or do you have to sign every .pyd and .dll inside the bundle (incl. python3xx.dll and third party wheels) before freezing?
  2. Has anyone seen Smart App Control actually stop blocking after signing, or does it still flag new files until reputation builds?
  3. onefile vs onedir, does it matter here? onefile extracts to temp, which feels like exactly what SAC hates.

If you've been through this, what did your build pipeline end up looking like?


r/Python • • 9h ago

News Train in Your Tab: PyTorch, JAX and ML Compilers in the Browser

5 Upvotes

Hi,
I'm sharing a blogpost about how we are now able to use PyTorch or Jax in your notebook in the browser ! : https://notebook.link/blog/train-in-your-tab/
Here some examples (be sure to use a WebGPU compatible browser):


r/Python • • 5h ago

News I built a local YouTube-to-Shorts clipper in Python 3.11+ using FFmpeg and deterministic DSP heurist

0 Upvotes

Hey r/Python! I wanted a way to automatically turn long YouTube videos into vertical 9:16 clips without paying for LLM APIs or running heavy PyTorch models on an old laptop.

How Max Clipper works under the hood:

- Explainable Clip Picking: Uses deterministic DSP and statistical heuristics (hook, audio energy, pacing, heatmap) instead of black-box LLMs—same input always gives the exact same output.

- Low-Spec Optimization: Built and tested on a 4th-gen Intel i5 with 8GB RAM and no GPU. Uses a global render lock to prevent FFmpeg CPU starvation, stall-based timeouts, and -preset ultrafast on <= 4 cores.

- Packaging: One-command installers for Linux/macOS/Windows plus Docker support.

Source Code (MIT License): https://github.com/4hmed1/MaxClipper

Would love code review or feedback on the clip-scoring heuristics!


r/Python • • 1d ago

Daily Thread Monday Daily Thread: Project ideas!

16 Upvotes

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" 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

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

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

Let's help each other grow. Happy coding! 🌟


r/Python • • 2d ago

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

32 Upvotes

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 • • 3d ago

Discussion pyinstall --onedir vs --onefile

19 Upvotes

Which one better? Currently I am using --onefile. But facing some tmpfs problem. What do you suggest?

Does --onefile actually shrinks the app size?


r/Python • • 3d ago

Daily Thread Saturday Daily Thread: Resource Request and Sharing! Daily Thread

5 Upvotes

Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

How it Works:

  1. Request: Can't find a resource on a particular topic? Ask here!
  2. Share: Found something useful? Share it with the community.
  3. Review: Give or get opinions on Python resources you've used.

Guidelines:

  • Please include the type of resource (e.g., book, video, article) and the topic.
  • Always be respectful when reviewing someone else's shared resource.

Example Shares:

  1. Book: "Fluent Python" - Great for understanding Pythonic idioms.
  2. Video: Python Data Structures - Excellent overview of Python's built-in data structures.
  3. Article: Understanding Python Decorators - A deep dive into decorators.

Example Requests:

  1. Looking for: Video tutorials on web scraping with Python.
  2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟


r/Python • • 4d ago

Discussion 684 PyPI packages run code at every Python start, and only 13 are ready for PEP 829

199 Upvotes

Python runs any line that starts with import in a .pth file in site-packages, every time it starts. You don't have to import the package. This year, the malicious releases of litellm (March and October) and agent-framework (November) all used a .pth file, so installing them was enough to run the credential stealer.

I wanted to see how many ordinary packages use the same feature. I took the latest release of 354,763 PyPI projects, found every .pth file with an import line, downloaded them and read them. The results:

  • 684 packages install a .pth file that runs on every Python start.
  • 244 of them run their own code: setuptools, coverage, coloredlogs, pywin32 and others. The other 440 only run old setuptools namespace boilerplate (-nspkg.pth).
  • coverage and coloredlogs do nothing unless you set an environment variable. urllib3-future copies its own files over your urllib3 folder at startup.
  • 52 packages put the file where Python never reads it on Linux or macOS, including files from temporary build folders that were packed by mistake.
  • Python 3.15 deprecates these import lines (PEP 829), and 3.18 will ignore them. Only 13 of the 244 packages already ship the replacement .start file.

The post includes a command that lists the .pth files with import lines in your own environment, and a table of what the 15 most downloaded ones do: https://py-code.org/blog/python-pth-files-pypi/


r/Python • • 4d ago

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

8 Upvotes

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:

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! 🌟


r/Python • • 5d ago

Discussion Microsoft's PyPI package got compromised without a GitHub code change. How is this even possible?

256 Upvotes

I was reading about yesterday's Microsoft Agent Framework security incident, and something caught my attention.

Apparently, attackers published two malicious versions (1.26.1 and 1.26.2) of Microsoft's official Python package on PyPI. These versions could steal cloud credentials just by starting Python.

Both versions were removed quickly.

What surprised me was that the malicious code wasn't even checked into Microsoft's GitHub repository.

From what I understand:

- Developers write code in GitHub.

- CI/CD builds it into a Python wheel (.whl).

- The wheel gets published to PyPI.

- When we run "pip install", we download that package.

But apparently, someone with the right publishing credentials can upload a malicious wheel directly, without going through the original GitHub repository.

That raises some interesting questions:

  1. How does PyPI verify that a package actually came from the legitimate source code and CI/CD pipeline?
  2. Why isn't a verified GitHub commit or build provenance mandatory for publishing updates to established packages?
  3. If publishing credentials are compromised, what prevents attackers from distributing malicious versions under trusted package names?
  4. Would mandatory attestations, release signing, or an approval process have prevented this?
  5. What protections should developers realistically use beyond simply trusting "pip install"?

I'm still learning about software supply-chain security, so I'd love to hear how experienced Python developers and security engineers think this should work.


r/Python • • 3d ago

Discussion Has this sub turned into python-security?

0 Upvotes

Each time l see this sub it's about wathever package I don't use that got compromised which I couldn't care less about. Now that all code showcase are banned, the new ways for sloppers to feel seen is report security issues. At least the former was still related to code, cybersecurity is another thing completely. I'd rathet see slop code showcases than a boring report about x package hacked


r/Python • • 5d ago

Resource CodePath’s free Spring 2027 courses are open: AI, cybersecurity, web dev, and coding interview prep

16 Upvotes

Hey everyone! If you’re a college student interested in Applied AI Engineering, Cybersecurity, Web Development, or Technical Interview Prep, check out CodePath’s free Spring 2027 courses.

I’m a Tech Fellow (TF) teaching Technical Interview Prep (TIP), and I highly recommend it if you want to learn data structures and algorithms in Python or get more comfortable with coding interviews. We practice breaking down problems, choosing the right data structure, and explaining our reasoning out loud. That last part makes a big difference when an interviewer asks you to walk through your approach.

If you’re interested, apply to CodePath here. That’s my referral link.

Happy to answer questions about TIP or what it’s like to take the course!


r/Python • • 6d ago

News microsoft agent-framework on PyPI was compromised twice in 33 minutes last night

459 Upvotes

1.26.1 and 1.26.2 both ship a credential stealer. It runs from a .pth file, so it executes at interpreter startup. Nothing has to import the package, a pip install in CI is enough. 1.26.1 got pulled, then 1.26.2 went up 33 minutes later with the same payload under different file names. Last clean release is 1.26.0.
complete details- https://safedep.io/blog/microsoft-agent-framework-pypi-compromise


r/Python • • 5d ago

Daily Thread Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

10 Upvotes

Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.


How it Works:

  1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
  2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
  3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

Guidelines:

  • This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
  • Keep discussions relevant to Python in the professional and educational context.

Example Topics:

  1. Career Paths: What kinds of roles are out there for Python developers?
  2. Certifications: Are Python certifications worth it?
  3. Course Recommendations: Any good advanced Python courses to recommend?
  4. Workplace Tools: What Python libraries are indispensable in your professional work?
  5. Interview Tips: What types of Python questions are commonly asked in interviews?

Let's help each other grow in our careers and education. Happy discussing! 🌟


r/Python • • 7d ago

Daily Thread Tuesday Daily Thread: Advanced questions

17 Upvotes

Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

How it Works:

  1. Ask Away: Post your advanced Python questions here.
  2. Expert Insights: Get answers from experienced developers.
  3. Resource Pool: Share or discover tutorials, articles, and tips.

Guidelines:

  • This thread is for advanced questions only. Beginner questions are welcome in our Daily Beginner Thread every Thursday.
  • Questions that are not advanced may be removed and redirected to the appropriate thread.

Recommended Resources:

Example Questions:

  1. How can you implement a custom memory allocator in Python?
  2. What are the best practices for optimizing Cython code for heavy numerical computations?
  3. How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?
  4. Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?
  5. How would you go about implementing a distributed task queue using Celery and RabbitMQ?
  6. What are some advanced use-cases for Python's decorators?
  7. How can you achieve real-time data streaming in Python with WebSockets?
  8. What are the performance implications of using native Python data structures vs NumPy arrays for large-scale data?
  9. Best practices for securing a Flask (or similar) REST API with OAuth 2.0?
  10. What are the best practices for using Python in a microservices architecture? (..and more generally, should I even use microservices?)

Let's deepen our Python knowledge together. Happy coding! 🌟


r/Python • • 8d ago

Resource I built git-wrapped: a Spotify-Wrapped-style summary of your git year (terminal report + shareable

11 Upvotes

What My Project Does

git-wrapped reads your local git history and gives you a "year in review": a colored contribution heatmap in your terminal, plus a shareable 1080x1350 card (SVG or PNG) with your commits, active days, longest streak, peak coding hour, top languages and a "persona" for your year (Night Owl, Early Bird, Weekend Warrior...).

It can scan a whole folder of repos at once and de-duplicates commits.

Target Audience

Any developer who wants a fun, shareable recap of their year. It's a hobby/side project, not production tooling.

Comparison

Many GitHub stats widgets rely on the GitHub API and a token. git-wrapped only runs `git log` locally, so it works offline, with private repos and non-GitHub repos, and it has no Python dependencies (PNG export uses a renderer you already have, like Chrome or rsvg-convert).

Usage

pip install git+https://github.com/Mohammadsdq/git-wrapped

git-wrapped ~/projects --year 2026 --png

My own year, for fun: 74 commits, peak hour 11pm, favorite commit word "upload" (10x). Apparently I'm a "Steady Builder".

Repo: Github Repo


r/Python • • 8d ago

Daily Thread Monday Daily Thread: Project ideas!

23 Upvotes

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" 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

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

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

Let's help each other grow. Happy coding! 🌟


r/Python • • 9d ago

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

25 Upvotes

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 • • 9d ago

Discussion Do Python-specific skills actually improve the agentic coding?

0 Upvotes

Hey folks! I’ve been playing with agentic coding and wondering if it’s actually worth adding Python-specific skills to my setup.

For those of you using them: which ones are genuinely useful? Any examples where a Python-specific skill noticeably improved the result vs just letting the agent figure things out on its own?


r/Python • • 10d ago

Daily Thread Saturday Daily Thread: Resource Request and Sharing! Daily Thread

14 Upvotes

Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

How it Works:

  1. Request: Can't find a resource on a particular topic? Ask here!
  2. Share: Found something useful? Share it with the community.
  3. Review: Give or get opinions on Python resources you've used.

Guidelines:

  • Please include the type of resource (e.g., book, video, article) and the topic.
  • Always be respectful when reviewing someone else's shared resource.

Example Shares:

  1. Book: "Fluent Python" - Great for understanding Pythonic idioms.
  2. Video: Python Data Structures - Excellent overview of Python's built-in data structures.
  3. Article: Understanding Python Decorators - A deep dive into decorators.

Example Requests:

  1. Looking for: Video tutorials on web scraping with Python.
  2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟


r/Python • • 11d ago

Discussion Why doesn't PyCharm warn about this type mismatch?

23 Upvotes

I'm using PyCharm with Python 3.13 and trying to implement a generic CQRS pattern.

I explicitly specify int as the response type, but PyCharm doesn't report any error when the handler returns str.

from abc import ABC, abstractmethod
from typing import Generic, TypeVar

TCommand = TypeVar("TCommand", bound="Command")
TResponse = TypeVar("TResponse")


class Command(ABC, Generic[TResponse]):
    pass


class CommandHandler(ABC, Generic[TCommand, TResponse]):
    @abstractmethod
    async def handle(self, command: TCommand) -> TResponse:
        pass


class CreateUserCommand(Command[int]):
    pass


class CreateUserCommandHandler(CommandHandler[CreateUserCommand, int]):
    async def handle(self, command: CreateUserCommand) -> str:
        return "123"


Is this expected behavior, or am I missing something in my generic type definitions?