Skip to content

Conversation

@rhettinger
Copy link
Contributor

@rhettinger rhettinger commented Oct 3, 2024

The or-operator is more concise and expressive than building a separate dictionary with generalized argument unpacking.


📚 Documentation preview 📚: https://cpython-previews--124941.org.readthedocs.build/

@rhettinger rhettinger added docs Documentation in the Doc dir skip issue skip news 3.14 bugs and security fixes labels Oct 3, 2024
def newfunc(*more_args, **more_keywords):
keywords_union = {**keywords, **more_keywords}
return func(*args, *more_args, **keywords_union)
return func(*args, *more_args, **keywords | more_keywords)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks confusing to me, because ** is closer to keywords than |. According to the PEP 8 style it looks like (**keywords) | more_keywords rather than **(keywords | more_keywords). I think it will be confusing for many readers.

To avoid confusion, you can add parentheses. Or leave the code as it is.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@rhettinger rhettinger enabled auto-merge (squash) October 3, 2024 19:33
@rhettinger rhettinger merged commit 7ecaf21 into python:main Oct 3, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.14 bugs and security fixes docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants