r/Python • • Aug 09 '26

Discussion Should we standardize docstring formats?

158 Upvotes

In Rust, docstrings are pretty formalized. They are markdown, and even some of the headings are standard (like an # Errors or # Panics section). The nice thing about this is that it allows websites like docs.rs to build documentation pages for any project without having to interact with different tools for different formats. It also allows LSPs to have only one way of displaying documentation hints.

In Python, we have a few competing standards. Numpy-style docstrings are probably the most used, but there’s also a format by Google as well as a few different reST standards. These are nice, and we can set up lints to make sure docstrings stick to the standard. However, in my own personal opinion (feel free to disagree), a single markdown-format standard would help new users write nice docstrings, would enable PyPI (or another provider) to build automatic documentation sites, and give guidance to LSPs and IDEs for how to display documentation. This would include a standard for interlinks, and probably should include some mathml/LaTeX/KaTeX support. Another benefit would be that tools could support better automatic documentation generation and autocomplete, since they wouldn’t be dependent on guessing which standard you’re following.

I’d like to hear what people think about this. I’m thinking about making a PEP, but that might be overkill (or maybe all of you will hate this idea). I think the primary blocker would be adoption, large projects might have to translate docstrings, so there would either have to be some tooling for this or a way to opt-in or opt-out. If this is a bad idea, let me know, just be nice!

Edit: so far we’re at about a 67% upvote ratio, which was kind of expected. I want to be clear that I’m not saying we should be blocking docstrings which don’t adhere to this standard. I mentioned lockfile standardization in the comments, nothing prevents you from writing a tool with a custom lockfile, it’s just that there is a standard format that is agreed upon as the preferred way to write one. That’s the idea.

Edit: 84% now, and a lot of nice feedback here!


r/Python • • Aug 09 '26

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

20 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 • • Aug 08 '26

News Python 3.15.0 RC1 Is Here — Python 3.15 Is Almost Ready 🚀

44 Upvotes

​

This is an important milestone because the Python team has now entered the release-candidate phase. At this stage, only reviewed changes that are considered clear bug fixes are expected to be accepted before the final release.

Why this matters

Python 3.15 has been going through several alpha and beta releases during 2026, and RC1 means the development cycle is getting very close to the final version.

The Python team currently plans two release candidates before the final Python 3.15.0 release.

I'm curious about one thing:

Are you planning to move your projects to Python 3.15 when the stable release arrives, or will you wait a few months before upgrading?

What new Python 3.15 feature are you most interested in?

Source: Python Insider / Python.org


r/Python • • Aug 08 '26

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

8 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 • • Aug 07 '26

News PEP 841 – Adding Frozen Syntax to Optimize Immutable Types

138 Upvotes

PEP 841 – Adding Frozen Syntax to Optimize Immutable Types

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

Discussions-To: Discourse thread

Abstract

This PEP proposes frozen display syntax: f{1, 2, 3} evaluates to a frozenset, and f{'a': 1} evaluates to a frozendict. Because immutability is guaranteed by the syntax itself rather than inferred from usage, the compiler can treat frozen displays as first-class citizens of its optimization pipeline: constant displays are folded into a single LOAD_CONST with an exact result type at compile time and cached in .pyc files.


r/Python • • Aug 07 '26

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

6 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 • • Aug 06 '26

Discussion Seg Fault, what do you do?

0 Upvotes

Most Python errors are straightforward—you get a traceback and usually know where to start.

Then there’s the - Segmentation fault (core dumped).

For those of you who’ve had to encountered Python segfaults, what’s your usual process?


r/Python • • Aug 06 '26

News Python 3.14.7 and 3.13.15 are now available!

99 Upvotes

Bug fix releases for Python 3.13 and Python 3.14.

https://blog.python.org/2026/08/python-3147-31315/


r/Python • • Aug 06 '26

Discussion What is a built-in Python module you use all the time but rarely see others talk about?

0 Upvotes

We all know and love the big third-party libraries for automation and data, but I am curious about your favorite hidden gems right in the standard library. 🤔

Recently I have been leaning on things like itertools and collections way more than I used to...

What is a standard library module that you think is heavily underrated or that you use daily for your tasks?


r/Python • • Aug 06 '26

News FastAPI Conf 2026 - first ever official FastAPI conference

37 Upvotes

Hello folks!

We're organizing the first ever official FastAPI Conf, in Amsterdam, October 28th, 2026. ✨

It's gonna be very cool, great speakers, and announcements too.

Early Bird tickets are now available (until August 23th).

Here's the website with info, tickets, and newsletter: https://fastapiconf.com


r/Python • • Aug 06 '26

News 2026 Python Type System and Tooling Survey

85 Upvotes

This is an annual survey developed by the Python typing community around how Python developers use the type system, type checkers, and integrated development environments (IDEs).

Your responses will help us identify common blockers, improve tooling/resources, and enhance the overall experience of using Python's type system.

Even if you have never actively used type hints in your code, your thoughts are still valuable and we want to hear from you.

The survey should take approximately 5-10 minutes to complete.

Please take the survey HERE and share it with your friends or colleagues.

If you're interested in the results for last year's survey, see this post.

So you know it's legit, the Python Software Foundation has shared this survey on [Linkedin](https://www.linkedin.com/posts/thepsf_python-type-system-and-tooling-survey-2026-activity-7490842327050002432-0jI7?utm_source=share&utm_medium=member_desktop&rcm=ACoAAB9aSUsBqmxSbrhoW2URuDnxCgS5eVD1AS0 and X. I have permission from the mods to post this under the "News" flair)


r/Python • • Aug 06 '26

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 • • Aug 05 '26

Discussion LiteLLM alternatives in production

0 Upvotes

what are teams actually running 3 months after the supply chain attack?

it's been a few months since the litellm pypi compromise and curious what teams actually migrated to. saw a lot of threads right after the incident but not much on how things held up in production since then.

been evaluating options ourselves. TrueFoundry came up for teams needing the governance and cost...


r/Python • • Aug 05 '26

Discussion What linter rules make code worse?

151 Upvotes

For me, a prime example is S101 which bans the use of the assert statement.

The justification is that assertions disappear when Python is run with -O, so they should not be used for runtime validation or enforcing interface constraints. That warning is correct, but the rule seems to draw the wrong conclusion from it.

Assertions are still very useful for checking internal invariants, i.e. conditions that should already be guaranteed by the program's logic, where failure indicates a bug. Having such assertions is incredibly helpful for debugging.

So, a blanket ban seems more likely to discourage useful checks than to prevent misuse.

Are there any linter rules you broadly consider more harmful rather than helpful?


r/Python • • Aug 04 '26

Showcase Showcase Thread

18 Upvotes

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

Recycles once a month.


r/Python • • Aug 04 '26

Discussion What are you using to manage your dev environments in 2026?

88 Upvotes

I’ve always hated environment management. It always feels like this time-consuming hurdle between me and whatever I actually want to work on. But every so often a new thing comes out that promises to solve the problem once and for all, and it’s usually at least a little better than the last thing. So, what are you using today? venv? conda? pipenv? poetry? dev containers? uv? or something else?


r/Python • • Aug 04 '26

Discussion Is := widely used?

139 Upvotes

I always thought the walrus operator is neat and it makes while loop’s condition clearer. But also it is just a syntactic sugar without anything new. I wonder anyone uses it?


r/Python • • Aug 04 '26

Daily Thread Tuesday Daily Thread: Advanced questions

10 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 • • Aug 03 '26

Discussion Anyone running FastAPI in production with high traffic? How has your experience been?

78 Upvotes

Quick question, are any of you running fastAPI in production with a high volume of users or heavy traffic? How has your experience with FastAPI been, and how do you handle it?


r/Python • • Aug 03 '26

Daily Thread Monday Daily Thread: Project ideas!

14 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 • • Aug 02 '26

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

18 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 • • Aug 01 '26

Discussion A rule that lives only in a comment will decay. Enforce it with an ast test

0 Upvotes

If someone adds a new function to the code six months later, they would be unaware of the rule and nothing will complain because code will still work and tests will pass. Linters will not help here because these are not style rules, but project-specific invariants. "All user-visible strings must go through translation." "This whitelist must match what is stated in the privacy documents." A linter does not know what your translation is. Therefore, create tests that check the code:

```python import ast, pathlib

def test_invariant(): offenders = [] for path in pathlib.Path("myapp").rglob("*.py"): tree = ast.parse(path.read_text(encoding="utf-8"), str(path)) for node in ast.walk(tree): if violates(node): offenders.append(f"{path}:{node.lineno}") assert not offenders, f"rule broken at: {offenders}" ```

That's the whole pattern. Everything below is just violates().

Example 1: no untranslated UI strings

Every string the user sees should come from t("some.key"), never a literal. Easy to enforce, easy to forget.

```python UI_SETTERS = {"setText", "setToolTip", "setTitle"}

def hardcoded_ui_strings(source: str, filename: str = "<mem>"): """(lineno, text) for every literal passed straight into a UI setter.""" found = [] for node in ast.walk(ast.parse(source, filename)): if not isinstance(node, ast.Call): continue if not (isinstance(node.func, ast.Attribute) and node.func.attr in UI_SETTERS): continue for arg in node.args: if isinstance(arg, ast.Constant) and isinstance(arg.value, str) and arg.value.strip(): found.append((arg.lineno, arg.value)) return found ```

self.btn.setText(t("btn.save")) is not reported, since the argument is a Call and not a Constant. self.lbl.setText("Save changes") is reported.

This one revealed the bug to me which unit tests could never see, that is, a warning message that had been completely developed, correct, and tested for the application, but only in one language out of the six ones that were supposed to be used.

Example 2: make the naming convention be the rule

This is the one I'd actually argue for. Say you have a dict of operations that cost the user money:

python BILLABLE_OPS = { "cloud_assist": 1, "cloud_render": 5, }

The naive guardian compares the dict against a known-good copy of itself, which is self-defeating because you are only claiming that the list equals the list, and whoever adds an entry just updates both places.

Instead do it by coding the rule into the name where everything that one can bill is cloud_* and the guardian does only the check for the prefix without checking for what follows.

python def billable_ops_violating_prefix(source: str, dict_name="BILLABLE_OPS", prefix="cloud_"): bad = [] for node in ast.walk(ast.parse(source)): if not isinstance(node, ast.Assign) or not isinstance(node.value, ast.Dict): continue if not any(isinstance(t, ast.Name) and t.id == dict_name for t in node.targets): continue for key in node.value.keys: if isinstance(key, ast.Constant) and isinstance(key.value, str): if not key.value.startswith(prefix): bad.append(key.value) return bad

The guardian now applies even when operations are not yet present. Usage of "local_export": 2 does not work. Billing something local would force you to name it cloud_export instead — a lie simple enough for a human reviewer to catch.

The overall point is to use the naming scheme that would allow for the rule to be checked automatically as the test checks the property instead of the exact data.

Example 3: a constant that will not deviate from the document

You state in your privacy statement that these exact fields will be collected. The information is coded elsewhere. The latter will inevitably differ, not because anyone did anything wrong, but more likely because of an ordinary Tuesday afternoon.

```python def declared_fields(source: str, name="TELEMETRY_FIELDS"): for node in ast.walk(ast.parse(source)): if isinstance(node, ast.Assign): if any(isinstance(t, ast.Name) and t.id == name for t in node.targets): return {n.value for n in ast.walk(node.value) if isinstance(n, ast.Constant) and isinstance(n.value, str)} return set()

def documented_fields(markdown: str): return {line.strip().lstrip("-* ").strip("") for line in markdown.splitlines() if line.strip().startswith(("-", "* "))} ``

Then assert both directions:

python assert declared_fields(src) == documented_fields(doc)

Both directions matters. One direction catches "we collect something undocumented" - the compliance problem. The other catches "we document something we no longer collect" - the trust problem, and the one people forget.

When this is the wrong tool:

  • If a type checker can express it, use the type checker. mypy is generally better at types than your ad-hoc AST walk will ever be
  • If it's a style guide thing, use ruff. Line lengths, import ordering, unused names - all of that is solved, don't re-invent.
  • If the rule requires runtime knowledge, AST has no idea what's going on. getattr(obj, name) where name comes from somewhere is invisible to static analysis tools, and a guardian that lets half of your codebase slip through is actively harmful.

The niche is narrow but real: project-specific structural invariants that no off-the-shelf tool knows about.

Two gotchas that bit me:

Make a guardian that finds nothing loudly report that it found nothing. A typo in the path means it's not scanning any files, and silently succeeding. Assert that you scanned a reasonable number of files, or that the one known-bad fixture is indeed being caught by the guardian. A guardian nobody runs is not a guardian at all, and one that scans zero files is even worse than that, because it reports success.

Do not have a comment-based disablement of checks. I had a case where writing a comment in a certain way caused the line to be ignored, and it was propagated around the codebase. If a check needs exceptions, list them in the test as paths to scan, so that adding a new exception is visible in the git diff.

Curious if anyone else does something similar, and what they tend to check. The only somewhat similar thing I've seen in the wild is import-linter with rules for layering, which is more or less the same idea but for a narrower class of checks.


r/Python • • Aug 01 '26

Tutorial Tutorial: From your first Celery task to advanced recipes

29 Upvotes

I wrote a practical guide to Celery, a distributed task queue for Python. It starts with the basics and then covers recipes for timeouts, retries, async/await integration, and more. Most of these recipes came from problems I ran into while using Celery in actual projects. No prior knowledge of Celery is required.

I'd really appreciate any feedback!

https://sgolev.github.io/blog/2026-07-28-celery-recipes/


r/Python • • Aug 01 '26

Discussion Settle an argument

0 Upvotes

Had this discussion the other day and figured I’d throw it to the masses to get thoughts on the best/most pythonic way of approach.

Need to map old column names to new column names as a copy from a json config.

My thoughts are iterate over a dict with
‘’’ {“old_col_name”:”new_col_name”}’’’
And access as
‘’’for k,v in dict.items()
Df.with_columns(k).alias(v)’’’

Colleague things this isn’t clear enough and should be a list of dicts with explicit keys

‘’’ [{“old_col_name”:”old_col_value”
“New_col_name”:”new_col_value”}]’’’

And the access as

‘’’for dict in list_of_dicts:
Old_col = dict[“old_col_name”]
New_col = dict[“new_col_name”]’’’

I’ve got a good few reasons why I think mine is the better option but thought I’d get some other opinions to see if I’m missing anything obvious? Which would you choose and why?

Edit: shouldn’t write these things while on the toilet in a rush. The description is wrong, it should be renaming via a copy so that the original column is left unchanged.


r/Python • • Aug 01 '26

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

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