Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-145644: Update function related explanations on "controlflow.rst"#145645

Open
hyperkai wants to merge 6 commits intopython:mainfrom
hyperkai:hyperkai-patch-7
Open

gh-145644: Update function related explanations on "controlflow.rst"#145645
hyperkai wants to merge 6 commits intopython:mainfrom
hyperkai:hyperkai-patch-7

Conversation

@hyperkai
Copy link

@hyperkaihyperkai commentedMar 8, 2026
edited by github-actionsbot
Loading

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

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

This is the tutorial:

  1. Exceptions messages must only be updated if they match the runtime message.
  2. Leave outvar-positional and other terminologies out of the tutorial. It will become too much for a beginner. Formal terms are better suited for formal documentation.



.. _tut-defaultargs:
.. _tut-defaultparams:
Copy link
Member

Choose a reason for hiding this comment

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

Changing this will break URLs, and blog post referrring to that.

and their order is not important. This also includes
non-optional arguments (e.g. ``parrot(voltage=1000)`` is valid too).
Noargument may receive a value more than once.
Noarguments are possible only if no required parameters exist.
Copy link
Member

Choose a reason for hiding this comment

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

This is not an equivalent sentence. We want to say that you cannot specify a parameter twice.

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function() got multiple values forargument 'a'
TypeError: function() got multiple values forparameter 'a'
Copy link
Member

Choose a reason for hiding this comment

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

Has this been changed at the C level? if not, don't change it.

receives a:ref:`tuple <tut-tuples>`containing thepositional
arguments beyondtheformal parameter list.(``*name`` must occur
before ``**name``.) For example,if we define a function like this::
When a finalvar-keyword parameter ``**name`` is present, itdefaults to an empty
Copy link
Member

Choose a reason for hiding this comment

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

Formal parameter is correct. And I would keep the "receives an empty dictionary" because it's really anew empty dictionary every time.

arguments beyondtheformal parameter list.(``*name`` must occur
before ``**name``.) For example,if we define a function like this::
When a finalvar-keyword parameter ``**name`` is present, itdefaults to an empty
dictionary (see :ref:`typesmapping`)to receive all keyword arguments except for
Copy link
Member

Choose a reason for hiding this comment

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

This is inaccurate. It's not meant to receive the keyword arguments. It's really a dictionary already containing the arguments.

Comment on lines +711 to +712
parameter ``*name`` (described in the next subsection) which defaults to an empty
:ref:`tuple<tut-tuples>`to receive allpositional arguments except for those received
Copy link
Member

Choose a reason for hiding this comment

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

This is also wrong.

before ``**name``.) For example,if we define a function like this::
When a finalvar-keyword parameter ``**name`` is present, itdefaults to an empty
dictionary (see:ref:`typesmapping`)to receive all keyword arguments except for
those corresponding toother parameters. This may be combined with avar-positional
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to introduce the terminology of "var-positional" or "var-keyword" in this tutorial.

------------------

By default, argumentsmay be passed to a Python function either by position
By default, argumentscan be passed to a Python function either by position
Copy link
Member

Choose a reason for hiding this comment

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

"may" is correct.


If ``/`` and ``*`` are not present in the function definition, arguments may
be passed to a function by position or by keyword.
Positional-or-keyword paremeters don't precede ``/``, don't follow ``*`` or ``*args``,
Copy link
Member

Choose a reason for hiding this comment

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

This is more confusing IMO.

>>>

But using ``/`` (positional only arguments), it is possible since it allows ``name`` as a positional argument and ``'name'`` as a key in the keyword arguments::
But using ``/`` (positional-only parameters) and calling ``foo()`` works because
Copy link
Member

Choose a reason for hiding this comment

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

Strictly speaking, you callfoo, notfoo().foo() is already the result of the call.

@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@picnixzpicnixzpicnixz requested changes

Assignees

No one assigned

Labels

awaiting changesdocsDocumentation in the Doc dirskip news

Projects

Status: Todo

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

"Defining Functions" to "Function Examples" section should be made better

2 participants

@hyperkai@picnixz

[8]ページ先頭

©2009-2026 Movatter.jp