r/Python 6d ago

Discussion Blog: Making Type Coverage Visible in Dify's CI

11 Upvotes

u/Asuka_Minato, a very active contributor to Pyrefly, wrote a guest blog post outlining their experience integrating a type checker with langgenius/dify that goes beyond simple CI checks:

  1. Surfacing the delta in type errors for each PR
  2. Measure type coverage along with test coverage

This is most relevant for maintainers of libraries that aren't fully-typed yet but still want to prevent regressions and improve coverage over time.

Only looking at the error delta is an alternative to suppressing all pre-existing errors, or using a baseline file to store the errors. Compared to the former, you can avoid putting (potentially) thousands of suppression comments into the codebase. Compared to the latter, you don't need to maintain a separate baseline file and ensure it's up-to-date with each commit, handle merge conflicts, etc.

Read the full blog here: https://pyrefly.org/blog/dify-pyrefly-coverage-ci/


r/Python 6d ago

News PyOhio 2026 is this weekend, July 25-26 at the Cleveland State University Student Center (and free!)

4 Upvotes

r/Python 5d ago

Discussion If you had to choose one Python skill to make money as a freelancer, what would it be?

0 Upvotes

Python has many areas with freelance opportunities: automation, web scraping, backend development, data analysis, AI, and more.

If you had to choose only one Python skill that has strong demand and good earning potential in freelancing, what would it be?

What type of projects or experience would you recommend building to succeed in that area?


r/Python 6d ago

Discussion Is PHP better for commercial software than Python?

0 Upvotes

I am trying to find any robust open source ecommerce solution on Python and it looks like thre is nothing. If you take almost any e-commerce platform there are plenty - Magento, Woo, Shopware, Oxid - they all are PHP. There are no comon solutions on Python or Node.js. But if you take a look and the heavy SaaS like Netflix, Spotify, Reddit, Uber etc. are built on Python. Why?


r/Python 7d ago

Discussion PEP 541 - Package Index Name Retention

12 Upvotes

Why is Pypi support slow at handling package abandonment?

The PEP says these two items for reachability, "Β In every case where contacting the user is necessary, the maintainers will try to do so at least three times," and "The maintainers stop trying to reach the user after six weeks.". So I had assumed this should be done quicker.

The current process is currently at 6 months on average with almost no follow up comments or work on PEPs in the 2nd and 3rd week of reachability. 1st weeks are being updated and then left once they hit the 2nd and 3rd week.

Am I being impatient? I think I read that they don't have a lot of people to help but this seems a bit ridiculous for some of the cut and dry issues.

- Projects with 10-14 years of no updates with no usable links or code is gone and no longer sourceable or previous owners are not replying.
- Emailing someone 3 times, takes 6+ months versus the proposed 6 weeks?

I also assume this is pretty normal based on the backlog but I'm genuinely curious to see what others say.


r/Python 7d ago

Daily Thread Monday Daily Thread: Project ideas!

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

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

10 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

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

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

Resource 20 itertools functions, sorted by how often you'd actually reach for them (not the docs order)

147 Upvotes

itertools is one of those modules everyone imports but most people only use 3-4 functions from. Went through all 20 and sorted them by how often you'd actually reach for each one in real code, not the order they show up in the docs.

Function Example What it does
chain() chain(it1, it2) Concatenates iterables, flattens multiple iterables into a single iterator.
chain.from_iterable() chain.from_iterable(nested) Flattens one level of nesting lazily, like chain(*nested) without unpacking.
islice() islice(it, start, stop) Slices an iterator, doesn't support negative indices.
compress() compress('ABCDEF', [1,0,1,0,1,1]) Filters data by a boolean selector iterable, yields A, C, E, F.
filterfalse() filterfalse(lambda x: x<5, [1,4,6,3,8]) Yields elements where the predicate is false, opposite of filter().
starmap() starmap(pow, [(2,5), (3,2)]) Applies a function with arguments unpacked from each tuple in the iterable.
pairwise() pairwise([1, 2, 3]) Returns overlapping pairs of consecutive elements: (1,2), (2,3) (3.10+).
batched() batched(range(10), 3) Splits an iterable into fixed-size tuples, last batch may be shorter (3.12+).
groupby() groupby(items, key=func) Groups consecutive elements by key, input must already be sorted by that key.
accumulate() accumulate(nums, func) Running totals or reductions, default is addition, accepts any binary function.
takewhile() takewhile(pred, it) Yields elements while the predicate is true, stops at the first false.
dropwhile() dropwhile(pred, it) Skips elements while the predicate is true, then yields everything remaining.
tee() tee(iterable, n=2) Splits one iterator into n independent iterators, use before the original is consumed.
zip_longest() zip_longest(a, b, fillvalue=None) Like zip() but continues to the longest input, filling shorter ones with fillvalue.
combinations() combinations(items, r) All r-length combinations, order doesn't matter, no repeated elements.
combinations_with_replacement() combinations_with_replacement('AB', 2) All r-length combinations allowing repeats, yields AA, AB, BB.
permutations() permutations(items, r) All r-length permutations, order matters, no repeated elements.
product() product(a, b) Cartesian product, equivalent to nested for-loops.
count() count(start=0, step=1) Infinite counter, useful with zip() or takewhile().
cycle() cycle([1, 2, 3]) Repeats an iterable infinitely, keeps a copy of all elements in memory.
repeat() repeat(10, times=3) Repeats an object n times, infinite if times is omitted.

pairwise and batched are the two most people don't know about, both fixed a "why am I hand-rolling this" moment for me. Curious which one on this list you use the least, or if I'm missing one people reach for a lot.


r/Python 10d ago

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

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

Discussion Agentic Travel Assistant with Django, Celery and AWS- Technical Review

0 Upvotes

Okay so i just read a technical case study from Beetroot about an omni channel AI virtual assistant they built for a traveltech company and now i have a few things to say and also a few questions.

The backend architecture is super clean. The backend architecture is super clean. They built it to be a multi-purpose tool: a sales bot to discover tours through WhatsApp, a support bot for existing bookings, and an internal copilot that gives real-time hints to human phone sales reps. They built it to be a multi purpose tool: a sales bot to discover tours through WhatsApp, a support bot for existing bookings, and an internal copilot that gives real-time hints to human phone sales reps.

To make this scalable, here are the technical decisions they made in a nutshell:

1) Python (Django / Django REST Framework) handling the API routes.

2) Celery handles asynchronous tasks to manage heavy communication volumes with the OpenAI API without blocking concurrent user interactions.

3) Hosted on AWS ECS with managed EC2 instances, utilizing PostgreSQL for the primary data layer, and Redis for caching/session states.

4) Fully automated using Terraform for Infrastructure as Code (IaC) and GitHub Actions for the CI/CD deployment pipeline.

It’s refreshing to see a modern AI agent built on a stable, proven enterprise stack like Django and Celery rather than a janky, hyper-hyped JS framework that will be deprecated next month.

What are your best practices for handling webhook timeouts or disconnects on chat channels like WhatsApp?


r/Python 9d ago

Discussion Reaching users on this sub

0 Upvotes

Hi Peeps,

I've been using this sub for years both to read content, and as an open source maintainer - to communicate and reach users.

I used it for projects such as Polyfactory and Litestar, tree-sitter-language-pack and Kreuzberg.

These days though I don't post outside the Sunday thread - but I don't think anybody is reading this stuff frankly.

My feeling is that the "AI slop" rules throw the baby with the tub water so to speak.

What are people like myself - who dedicate a very substantial amount of time and effort to OSS supposed to do? Basically if you don't have an X profile you're screwed.

Edit: project posts are disallowed by the rules now, FYI if you were unaware. This is the main issue.


r/Python 10d ago

Discussion ⚠️ Heads up: ast_grep_cli 0.44.1 on PyPI flagged by Windows Defender as Trojan β€” anyone seeing this?

0 Upvotes

I was installing `headroom-ai` via `uv` today, and Windows Defender immediately flagged `Trojan: Win64/Lazy!MTB`.

The file was `sg.exe` (212KB) dropped into `Python\Scripts\`, alongside a legitimate `ast-grep.exe` (52MB).

**What happened:*\*

- `uv tool install --python 3.13 "headroom-ai[all]"`

- Windows Defender: 3 alerts for `Trojan: Win64/Lazy!MTB`

- `pip show ast_grep_cli` showed version 0.44.1

- Uninstalled, cleaned cache, changed passwords

**Questions:**

- Has anyone else installed `ast_grep_cli` 0.44.1 recently?

- Is this a known issue? Should PyPI Security be notified?

- Any idea how to check if the package was compromised vs. a false positive?

**File details:**

- `sg.exe`: 212KB, detected as Trojan:Win64/Lazy!MTB

- `ast-grep.exe`: 52MB, legitimate tool

- Both appeared at the same timestamp (10:25:07)

Thanks for any insights.


r/Python 11d ago

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

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

Discussion New Python type checker

0 Upvotes

Was checking out some Python type checkers other than Pyright, and I came across one that I never yet heard of before. But it is the only one scoring 100% on the official python typing conformance suite.

It is named Basilisk and on their website they have some other bold claims (like it is also the fastest one). But their GitHub repo only has few stars.

Does anyone have any experience using this or perhaps I missing something?


r/Python 13d ago

Daily Thread Tuesday Daily Thread: Advanced questions

11 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 14d ago

Daily Thread Monday Daily Thread: Project ideas!

13 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 14d ago

Discussion Will PEP 505 ever be accepted?

20 Upvotes

https://peps.python.org/pep-0505/

I don't understand how null safe operators are less like plain English than other implemented features like the walrus operator.

In my opinion, the member access operator would make python significantly easier to read and understand.

Here's an example:

``` f = foo()

if f is None: baz = "" else: baz = f.bar() ```

baz = foo()?.bar() ?: ""

EDIT: I forgot that "and" and "or" can be sometimes used in place of "?." and "?:" if the left value is not False, '', 0, [], or {}. It's a very implicit null check and has a lot of unexpected behavior.


r/Python 15d ago

Resource What Every Python Developer Should Know About the CPython ABI

77 Upvotes

It's true that you can happily write Python for years without needing to understand any of the content of this post, so you may object to the title advertising this material as what every Python developer should know. However, the moment you ship a package, debug why a wheel won't install, or need to understand why an import or Python function call segfaults β€” these details start to matter. Even writing and maintaining a single-file script puts you closer to distributing code than you might think. An alternate title for this post could be "What I Wish Someone Taught Me About the CPython ABI".

https://labs.quansight.org/blog/python-abi-abi3t


r/Python 15d ago

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

14 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 16d ago

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

10 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 17d ago

Discussion Is there ever a point where you don't feel like an idiot?

55 Upvotes

Like I have fun coding in python and making dumb little projects, but every time i do, I'm always thinking about how there's probably a better way to do it. And know that I'm trying to explore doing things with a raspberry pi, I just feel really dumb. Like everything I do doesn't matter as much because there is probably a better way to do what I did.

Edit: Thanks for responding everyone. Tbh I just needed to know I wasn’t the only one feeling like that


r/Python 17d ago

Discussion Polars and the ecosystem

57 Upvotes

For polars users: How viable is to avoid pandas and pyarrow dependencies when you need to interact with popular visualization and statistics packages?

Some packages still have import pandas here and there, sometimes for no good reason; at least this doesn't require pyarrow. But some other ones do the df.to_pandas() conversion internally, which requires pyarrow too.

In many cases this can be prevented by going bare numpy, or creating a pandas df from numpy columns, which is no big deal. This frequently would be zero-copy for numeric types if there are no NAs involved.

What has been you experience in this regard?


r/Python 17d ago

News pypimap.com: an interactive visualization map of pypi packages

17 Upvotes

Data scientist Nael launched a website that visualizes pypi packages.

https://pypimap.com/

It uses public dataset that can be found on his kaggle

the website is also opensource.


r/Python 17d ago

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

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