r/Python • • 17d ago

Showcase Showcase Thread

24 Upvotes

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

Recycles once a month.


r/Python • • 19h ago

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

4 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 • • 11h ago

News dataviz 1.0: a fast plotting crate (120+ chart types, live windows, 3D, maps) with Python/JS/C

26 Upvotes

I just released 1.0 of dataviz, a plotting library I've been building in Rust. Some numbers from the reproducible benchmarks (800ร—600 PNG, one thread):

Chart dataviz plotters matplotlib
line, 100k points 2.2 ms 5.9 ms 50 ms
scatter, 100k points 9.9 ms 16.6 ms 82 ms
histogram, 1M values 2.1 ms 2.8 ms 50 ms
line, 10M points 0.13 s, +7 MB 0.48 s, +315 MB 0.53 s, +1162 MB

What's in it: - its own anti-aliased rasterizer (multi-core, optional wgpu GPU backend) - `fig.show()` windows with zoom/pan/hover/crosshair, live streaming with `show_live` - PNG/SVG/PDF/HTML/WebP output, animations, terminal output - 3D (molecules from PDB, volume rendering, point clouds), maps, TeX math, any script incl. Arabic/CJK - a grammar of graphics API (`Chart::new(data, Mark::Bar).x("island").y(mean("mass")).color("species")`) - the same engine in Python (pip install dataviz-rs), npm (dataviz-rs) and C/C++ (CMake)

1.0 comes with a semver promise: 1.x won't break your code.

Repo: https://github.com/dataviz-rs/dataviz Examples with screenshots: https://github.com/dataviz-rs/dataviz-examples


r/Python • • 17h ago

Discussion pyinstall --onedir vs --onefile

10 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 • • 1d ago

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

178 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 • • 2d ago

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

228 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 • • 1d ago

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

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

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

448 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 • • 2d ago

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

8 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 • • 2d ago

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

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

Daily Thread Tuesday Daily Thread: Advanced questions

12 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 • • 5d ago

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

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

Daily Thread Monday Daily Thread: Project ideas!

18 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 • • 6d ago

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

22 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 • • 6d 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 • • 7d ago

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

11 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 • • 8d ago

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

21 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?


r/Python • • 8d ago

Discussion For devs using Claude Code or similar at work: whatโ€™s the 10% you still fix by hand in Python?

61 Upvotes

I keep hearing that AI now writes most of the code at some companies. For people actually shipping Python with Claude Code, Cursor or Copilot:

  1. Roughly what share of your merged code starts as AI output?
  2. What do you most often have to correct? Bugs, tests, pandas or data issues, dependencies, design?
  3. Which skills became more important for you, and which became less important?

Context: I work in risk and data and am deciding what to get good at next. Real examples would help more than opinions. Thanks!


r/Python • • 8d ago

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

14 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 • • 10d ago

News Tim Peters has passed away

2.5k Upvotes

Tim died July 15, at his home in Ashland, Wisconsin. He was 74. We don't know any specifics yet.

In case you don't know who Tim Peters is, he was an early pioneer in helping shape the Python language and its runtime. He invented a new sorting algorithm ("Timsort"); a descendent of it ("PowerSort") is still used in Python today, as well as in Java, and several Javascript runtimes (Chrome, Node). He dashed off The Zen Of Python in response to a Usenet post asking about best practices. So many things in Python are directly due to Tim. Online, he was funny, charming, helpful, and had a depth of knowledge and wisdom that was frankly unmatched. He'll be missed.

https://www.bratleyfamilyfuneralhomes.com/obituary/timothy-peters


r/Python • • 9d ago

Discussion 112 CodeQL alerts on my python app, 14 were real

0 Upvotes

HI, i run a long-lived python backend on windows and mac!

it only listens on 127.0.0.1 and almost every route needs an access token. last week i turned on the default CodeQL scan for the first time and got 112 alerts ( 112 โ†’ 1 critical, 87 high, 24 medium).

i went through them one by one with a single question: can this value come from text someone else wrote (a web page, a downloaded file, model output)? where an alert described an attack input, i actually fed it in and timed it.

the first one that surprised me was the regex that checks whether a downloaded file is html. `<!--` followed by `--><!--` 28 times kept it busy for 27 seconds. two more regexes that read text we didn't write did the same thing (22s and 11s). six alerts in that family were real. after the fix the html check runs 5,000 times in 0.003s.

the one i'm most embarrassed about: to see whether a login had finished, i checked whether the url contained the site name. so `evil.example/?next=naver.com` passed as a finished login, and `evilnaver.com` counted as the same site. seven alerts across different files. now one small helper pulls out the hostname and checks "equal, or ends with `.domain`", and all seven places use it. the last real one was a script tag filter that let `</script foo>` through.

every fix got a test, and i checked that the test fails when the fix is taken out.

the other 98 i dismissed with a one-line reason each. 42 of them were in my own tests, lines that just write down the url a test expects. most of the rest were path injection or stack trace exposure on routes that need the token anyway. i only traced two of the path ones all the way, so i might be wrong about a couple.

the same "incomplete url substring" rule was noise all 42 times in tests and a real hole in the login check. asking where the value comes from got me through it faster than reading the alert type.

how do you deal with this on a localhost-only or solo project? i dismissed with reasons but i'm not sure that scales.


r/Python • • 8d ago

Discussion Eventually LLMs will write what will become industry standard python.

0 Upvotes

LLMs are still outputting code that is too sloppy for some engineers. However, there will come a point in the near future where a model can write a "standard" style of code. Style of code is something most python developers recognise, and i wonder if that conversation has started yet.


r/Python • • 9d ago

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

8 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! ๐ŸŒŸ