Skip to content

Conversation

jeff14994
Copy link

@jeff14994 jeff14994 commented Sep 5, 2025

This PR updates section 4.9.1 of the tutorial to clarify that arguments without default values must come before arguments with default values.

Current text:

The most useful form is to specify a default value for one or more arguments. This creates a function that can be called with fewer arguments than it is defined to allow.

Proposed text:

The most useful form is to specify a default value for one or more arguments. All arguments without default values must come first, followed by those with defaults. This allows a function to be called with fewer arguments than it is defined to allow.

Closes gh-87209.


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

@python-cla-bot
Copy link

python-cla-bot bot commented Sep 5, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@@ -588,8 +588,9 @@ Default Argument Values
-----------------------

The most useful form is to specify a default value for one or more arguments.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The most useful form is to specify a default value for one or more arguments.
The most useful form is to specify a default value for one or more parameters.

This is talking about parameters, not arguments.

Comment on lines 591 to 593
All arguments without default values must come first, followed by those with
defaults. This allows a function to be called with fewer arguments than it is
defined to allow. For example::
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
All arguments without default values must come first, followed by those with
defaults. This allows a function to be called with fewer arguments than it is
defined to allow. For example::
All positional only parameters (that is, without default values) must come first, followed by those with
defaults. This allows a function to be called with fewer arguments than it is
defined to allow. For example::

I think we should be introducing the proper terminology?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, good point. I'll update this section to use parameters consistently since that's the proper terminology in this context. Appreciate the clarification!

@jeff14994
Copy link
Author

Hi @StanFromIreland,

I’ve updated the body to use parameters consistently. Let me know if you spot anything else. Thanks!

Comment on lines 590 to 593
The most useful form is to specify a default value for one or more parameters.
All positional only parameters (that is, without default values) must come first, followed by those with
defaults. This allows a function to be called with fewer arguments than it is
defined to allow. For example::
Copy link
Member

Choose a reason for hiding this comment

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

Please ensure all lines are wrapped to 79 characters.

@jeff14994
Copy link
Author

Hi @StanFromIreland,

I’ve updated the section so that all lines are wrapped at 79 characters as requested. Please let me know if there’s anything else I should adjust.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

Python tutorial could make rules for default argument definition clearer
2 participants