Movatterモバイル変換


[0]ホーム

URL:


Following system colour schemeSelected dark colour schemeSelected light colour scheme

Python Enhancement Proposals

PEP 570 – Python Positional-Only Parameters

Author:
Larry Hastings <larry at hastings.org>,Pablo Galindo Salgado <pablogsal at python.org>,Mario Corchero <mariocj89 at gmail.com>,Eric N. Vander Weele <ericvw at gmail.com>
BDFL-Delegate:
Guido van Rossum <guido at python.org>
Discussions-To:
Discourse thread
Status:
Final
Type:
Standards Track
Created:
20-Jan-2018
Python-Version:
3.8

Table of Contents

Abstract

This PEP proposes to introduce a new syntax,/, for specifyingpositional-only parameters in Python function definitions.

Positional-only parameters have no externally-usable name. When a functionaccepting positional-only parameters is called, positional arguments are mappedto these parameters based solely on their order.

When designing APIs (application programming interfaces), libraryauthors try to ensure correct and intended usage of an API. Without the ability tospecify which parameters are positional-only, library authors must be carefulwhen choosing appropriate parameter names. This care must be takeneven for required parameters or when the parametershave no external semantic meaning for callers of the API.

In this PEP, we discuss:

  • Python’s history and current semantics for positional-only parameters
  • the problems encountered by not having them
  • how these problems are handled without language-intrinsic support forpositional-only parameters
  • the benefits of having positional-only parameters

Within context of the motivation, we then:

  • discuss why positional-only parameters should be a feature intrinsic to thelanguage
  • propose the syntax for marking positional-only parameters
  • present how to teach this new feature
  • note rejected ideas in further detail

Motivation

History of Positional-Only Parameter Semantics in Python

Python originally supported positional-only parameters. Early versions of thelanguage lacked the ability to call functions with arguments bound to parametersby name. Around Python 1.0, parameter semantics changed to bepositional-or-keyword. Since then, users have been able to provide argumentsto a function either positionally or by the keyword name specified in thefunction’s definition.

In current versions of Python, many CPython “builtin” and standard libraryfunctions only accept positional-only parameters. The resulting semantics can beeasily observed by calling one of these functions using keyword arguments:

>>>help(pow)...pow(x, y, z=None, /)...>>>pow(x=5,y=3)Traceback (most recent call last):  File"<stdin>", line1, in<module>TypeError:pow() takes no keyword arguments

pow() expresses that its parameters are positional-only via the/ marker. However, this is only a documentation convention; Pythondevelopers cannot use this syntax in code.

There are functions with other interesting semantics:

  • range(), an overloaded function, accepts an optional parameter to theleft of its required parameter.[4]
  • dict(), whose mapping/iterator parameter is optional and semanticallymust be positional-only. Any externally visible name for this parameterwould occlude that name going into the**kwarg keyword variadic parameterdict.[3]

One can emulate these semantics in Python code by accepting(*args,**kwargs) and parsing the arguments manually. However, this resultsin a disconnect between the function definition and what the functioncontractually accepts. The function definition does not match the logic of theargument handling.

Additionally, the/ syntax is used beyond CPython for specifying similarsemantics (i.e.,[1][2]); thus, indicating thatthese scenarios are not exclusive to CPython and the standard library.

Problems Without Positional-Only Parameters

Without positional-only parameters, there are challenges for library authorsand users of APIs. The following subsections outline the problemsencountered by each entity.

Challenges for Library Authors

With positional-or-keyword parameters, the mix of calling conventions is notalways desirable. Authors may want to restrict usage of an API by disallowingcalling the API with keyword arguments, which exposes the name of the parameter whenpart of the public API. This approach is especially useful for required functionparameters that already have semantic meaning (e.g,namedtuple(typenames,field_names,…) or when the parameter name has notrue external meaning (e.g.,arg1,arg2, …, etc formin()). If acaller of an API starts using a keyword argument, the library author cannot renamethe parameter because it would be a breaking change.

Positional-only parameters can be emulated by extracting arguments from*args one by one. However, this approach is error-prone and is notsynonymous with the function definition, as previously mentioned. The usage ofthe function is ambiguous and forces users to look athelp(), theassociated auto-generated documentation, or source code to understand whatparameters the function contractually accepts.

Challenges for Users of an API

Users may be surprised when first encountering positional-only notation. Thisis expected given that it has only recently been documented[13] and it is not possible to use in Python code. Forthese reasons, this notation is currently an outlier that appears only inCPython APIs developed in C. Documenting the notation and making it possibleto use it in Python code would eliminate this disconnect.

Furthermore, the current documentation for positional-only parameters is inconsistent:

  • Some functions denote optional groups of positional-only parameters byenclosing them in nested square brackets.[5]
  • Some functions denote optional groups of positional-only parameters bypresenting multiple prototypes with varying numbers of parameters.[6]
  • Some functions useboth of the above approaches.[4][7]

Another point the current documentation does not distinguish iswhether a function takes positional-only parameters.open() accepts keywordarguments; however,ord() does not — there is no way of telling just byreading the existing documentation.

Benefits of Positional-Only Parameters

Positional-only parameters give more control to library authors to betterexpress the intended usage of an API and allows the API to evolve in a safe,backward-compatible way. Additionally, it makes the Python language moreconsistent with existing documentation and the behavior of various“builtin” and standard library functions.

Empowering Library Authors

Library authors would have the flexibility to change the name ofpositional-only parameters without breaking callers. This flexibility reduces thecognitive burden for choosing an appropriate public-facing name for requiredparameters or parameters that have no true external semantic meaning.

Positional-only parameters are useful in several situations such as:

  • when a function accepts any keyword argument but also can accept a positional one
  • when a parameter has no external semantic meaning
  • when an API’s parameters are required and unambiguous

A keyscenario is when a function accepts any keyword argument but can also accepts apositional one. Prominent examples areFormatter.format anddict.update. For instance,dict.update accepts a dictionary(positionally), an iterable of key/value pairs (positionally), or multiplekeyword arguments. In this scenario, if the dictionary parameter were notpositional-only, the user could not use the name that the function definitionuses for the parameter or, conversely, the function could not distinguisheasily if the argument received is the dictionary/iterable or a keywordargument for updating the key/value pair.

Another scenario where positional-only parameters are useful is when theparameter name has no true external semantic meaning. For example, let’s saywe want to create a function that converts from one type to another:

defas_my_type(x):...

The name of the parameter provides no intrinsic value and forces the API authorto maintain its name forever since callers might passx as a keywordargument.

Additionally, positional-only parameters are useful when an API’s parametersare required and is unambiguous with respect to function. For example:

defadd_to_queue(item:QueueItem):...

The name of the function makes clear the argument expected. A keywordargument provides minimal benefit and also limits the future evolution of theAPI. Say at a later time we want this function to be able to take multipleitems, while preserving backwards compatibility:

defadd_to_queue(items:Union[QueueItem,List[QueueItem]]):...

or to take them by using argument lists:

defadd_to_queue(*items:QueueItem):...

the author would be forced to always keep the original parameter name to avoidpotentially breaking callers.

By being able to specify positional-only parameters, an author can change thename of the parameters freely or even change them to*args, as seen in theprevious example. There are multiple function definitions in the standardlibrary which fall into this category. For example, the required parameter tocollections.defaultdict (calleddefault_factory in its documentation) canonly be passed positionally. One special case of this situation is theselfparameter for class methods: it is undesirable that a caller can bind bykeyword to the nameself when calling the method from the class:

io.FileIO.write(self=f,b=b"data")

Indeed, function definitions from the standard library implemented in C usuallytakeself as a positional-only parameter:

>>>help(io.FileIO.write)Help on method_descriptor:write(self, b, /)    Write buffer b to file, return number of bytes written.

Improving Language Consistency

The Python language would be more consistent with positional-onlyparameters. If the concept is a normal feature of Python rather than a featureexclusive to extension modules, it would reduce confusion for usersencountering functions with positional-only parameters. Some majorthird-party packages are already using the/ notation in their functiondefinitions[1][2].

Bridging the gap found between “builtin” functions whichspecify positional-only parameters and pure Python implementations that lackthe positional syntax would improve consistency. The/ syntax is already exposedin the existing documentation such as when builtins and interfaces are generatedby the argument clinic.

Another essential aspect to consider isPEP 399, which mandates thatpure Python versions of modules in the standard librarymust have the sameinterface and semantics that the accelerator modules implemented in C. Forexample, ifcollections.defaultdict were to have a pure Pythonimplementation it would need to make use of positional-only parameters to matchthe interface of its C counterpart.

Rationale

We propose to introduce positional-only parameters as a new syntax to thePython language.

The new syntax will enable library authors to further control how their APIcan be called. It will allow designating which parameters must be called aspositional-only, while preventing them from being called as keyword arguments.

Previously, (informational)PEP 457 defined the syntax, but with a much more vaguescope. This PEP takes the original proposal a step further by justifyingthe syntax and providing an implementation for the/ syntax in functiondefinitions.

Performance

In addition to the aforementioned benefits, the parsing and handling ofpositional-only arguments is faster. This performance benefit can bedemonstrated in this thread about converting keyword arguments to positional:[11]. Due to this speedup, there has been a recenttrend towards moving builtins away from keyword arguments: recently,backwards-incompatible changes were made to disallow keyword arguments tobool,float,list,int,tuple.

Maintainability

Providing a way to specify positional-only parameters in Python will make iteasier to maintain pure Python implementations of C modules. Additionally,library authors defining functions will have the choice for choosingpositional-only parameters if they determine that passing a keyword argumentprovides no additional clarity.

This is a well discussed, recurring topic on the Python mailing lists:

Logical ordering

Positional-only parameters also have the (minor) benefit of enforcing somelogical order when calling interfaces that make use of them. For example, therange function takes all its parameters positionally and disallows formslike:

range(stop=5,start=0,step=2)range(stop=5,step=2,start=0)range(step=2,start=0,stop=5)range(step=2,stop=5,start=0)

at the price of disallowing the use of keyword arguments for the (unique)intended order:

range(start=0,stop=5,step=2)

Compatibility for Pure Python and C Modules

Another critical motivation for positional-only parameters isPEP 399:Pure Python/C Accelerator Module Compatibility Requirements. ThisPEP states that:

This PEP requires that in these instances that the C code must pass thetest suite used for the pure Python code to act as much as a drop-inreplacement as reasonably possible

If the C code is implemented using the existing capabilitiesto implement positional-only parameters using the argument clinic, and relatedmachinery, it is not possible for the pure Python counterpart to match theprovided interface and requirements. This creates a disparity between theinterfaces of some functions and classes in the CPython standard library andother Python implementations. For example:

$ python3 # CPython 3.7.2>>> import binascii; binascii.crc32(data=b'data')TypeError: crc32() takes no keyword arguments$ pypy3 # PyPy 6.0.0>>>> import binascii; binascii.crc32(data=b'data')2918445923

Other Python implementations can reproduce the CPython APIs manually, but thisgoes against the spirit ofPEP 399 to avoid duplication of effort bymandating that all modules added to Python’s standard librarymust have apure Python implementation with the same interface and semantics.

Consistency in Subclasses

Another scenario where positional-only parameters provide benefit occurs when asubclass overrides a method of the base class and changes the name of parametersthat are intended to be positional:

classBase:defmeth(self,arg:int)->str:...classSub(Base):defmeth(self,other_arg:int)->str:...deffunc(x:Base):x.meth(arg=12)func(Sub())# Runtime error

This situation could be considered a Liskov violation — the subclass cannot beused in a context when an instance of the base class is expected. Renamingarguments when overloading methods can happen when the subclass has reasons touse a different choice for the parameter name that is more appropriate for thespecific domain of the subclass (e.g., when subclassingMapping toimplement a DNS lookup cache, the derived class may not want to use the genericargument names ‘key’ and ‘value’ but rather ‘host’ and ‘address’). Having thisfunction definition with positional-only parameters can avoid this problembecause users will not be able to call the interface using keyword arguments.In general, designing for subclassing usually involves anticipating code thathasn’t been written yet and over which the author has no control. Havingmeasures that can facilitate the evolution of interfaces in abackwards-compatible would be useful for library authors.

Optimizations

A final argument in favor of positional-only parameters is that they allow somenew optimizations like the ones already present in the argument clinic due tothe fact that parameters are expected to be passed in strict order. For example, CPython’sinternalMETH_FASTCALL calling convention has been recently specialized forfunctions with positional-only parameters to eliminate the cost for handlingempty keywords. Similar performance improvements can be applied when creatingthe evaluation frame of Python functions thanks to positional-only parameters.

Specification

Syntax and Semantics

From the “ten-thousand foot view”, eliding*args and**kwargs forillustration, the grammar for a function definition would look like:

defname(positional_or_keyword_parameters,*,keyword_only_parameters):

Building on that example, the new syntax for function definitions would looklike:

defname(positional_only_parameters,/,positional_or_keyword_parameters,*,keyword_only_parameters):

The following would apply:

  • All parameters left of the/ are treated as positional-only.
  • If/ is not specified in the function definition, that function does notaccept any positional-only arguments.
  • The logic around optional values for positional-only parameters remains thesame as for positional-or-keyword parameters.
  • Once a positional-only parameter is specified with a default, thefollowing positional-only and positional-or-keyword parameters need to havedefaults as well.
  • Positional-only parameters which do not have defaultvalues arerequired positional-only parameters.

Therefore, the following would be valid function definitions:

defname(p1,p2,/,p_or_kw,*,kw):defname(p1,p2=None,/,p_or_kw=None,*,kw):defname(p1,p2=None,/,*,kw):defname(p1,p2=None,/):defname(p1,p2,/,p_or_kw):defname(p1,p2,/):

Just like today, the following would be valid function definitions:

defname(p_or_kw,*,kw):defname(*,kw):

While the following would be invalid:

defname(p1,p2=None,/,p_or_kw,*,kw):defname(p1=None,p2,/,p_or_kw=None,*,kw):defname(p1=None,p2,/):

Full Grammar Specification

A simplified view of the proposed grammar specification is:

typedargslist:tfpdef['='test](','tfpdef['='test])*',''/'[','# and so onvarargslist:vfpdef['='test](','vfpdef['='test])*',''/'[','# and so on

Based on the reference implementation in this PEP, the new rule fortypedarglist would be:

typedargslist:(tfpdef['='test](','tfpdef['='test])*',''/'[','[tfpdef['='test](','tfpdef['='test])*[','['*'[tfpdef](','tfpdef['='test])*[','['**'tfpdef[',']]]|'**'tfpdef[',']]]|'*'[tfpdef](','tfpdef['='test])*[','['**'tfpdef[',']]]|'**'tfpdef[',']]])|(tfpdef['='test](','tfpdef['='test])*[','['*'[tfpdef](','tfpdef['='test])*[','['**'tfpdef[',']]]|'**'tfpdef[',']]]|'*'[tfpdef](','tfpdef['='test])*[','['**'tfpdef[',']]]|'**'tfpdef[','])

and forvarargslist would be:

varargslist:vfpdef['='test](','vfpdef['='test])*',''/'[','[(vfpdef['='test](','vfpdef['='test])*[','['*'[vfpdef](','vfpdef['='test])*[','['**'vfpdef[',']]]|'**'vfpdef[',']]]|'*'[vfpdef](','vfpdef['='test])*[','['**'vfpdef[',']]]|'**'vfpdef[','])]]|(vfpdef['='test](','vfpdef['='test])*[','['*'[vfpdef](','vfpdef['='test])*[','['**'vfpdef[',']]]|'**'vfpdef[',']]]|'*'[vfpdef](','vfpdef['='test])*[','['**'vfpdef[',']]]|'**'vfpdef[','])

Semantic Corner Case

The following is an interesting corollary of the specification.Consider this function definition:

deffoo(name,**kwds):return'name'inkwds

There is no possible call that will make it returnTrue.For example:

>>>foo(1,**{'name':2})Traceback (most recent call last):  File"<stdin>", line1, in<module>TypeError:foo() got multiple values for argument 'name'>>>

But using/ we can support this:

deffoo(name,/,**kwds):return'name'inkwds

Now the above call will returnTrue.

In other words, the names of positional-only parameters can be used in**kwds without ambiguity. (As another example, this benefits thesignatures ofdict() anddict.update().)

Origin of “/” as a Separator

Using/ as a separator was initially proposed by Guido van Rossumin 2012[8] :

Alternative proposal: how about using ‘/’ ? It’s kind of the oppositeof ‘*’ which means “keyword argument”, and ‘/’ is not a new character.

How To Teach This

Introducing a dedicated syntax to mark positional-only parameters is closelyanalogous to existing keyword-only arguments. Teaching these concepts togethermaysimplify how to teach the possible function definitions a user may encounter ordesign.

This PEP recommends adding a new subsection to the Python documentation, in thesection“More on Defining Functions”, where the rest of the argument typesare discussed. The following paragraphs serve as a draft for these additions.They will introduce the notation for both positional-only andkeyword-only parameters. It is not intended to be exhaustive, nor should it beconsidered the final version to be incorporated into the documentation.


By default, arguments may be passed to a Python function either by positionor explicitly by keyword. For readability and performance, it makes sense torestrict the way arguments can be passed so that a developer need only lookat the function definition to determine if items are passed by position, byposition or keyword, or by keyword.

A function definition may look like:

deff(pos1,pos2,/,pos_or_kwd,*,kwd1,kwd2):-------------------------------||||Positionalorkeyword||-Keywordonly--Positionalonly

where/ and* are optional. If used, these symbols indicate the kind ofparameter by how the arguments may be passed to the function:positional-only, positional-or-keyword, and keyword-only. Keyword parametersare also referred to as named parameters.

Positional-or-Keyword Arguments

If/ and* are not present in the function definition, arguments maybe passed to a function by position or by keyword.

Positional-Only Parameters

Looking at this in a bit more detail, it is possible to mark certain parametersaspositional-only. Ifpositional-only, the parameters’ order matters, andthe parameters cannot be passed by keyword. Positional-only parameters wouldbe placed before a/ (forward-slash). The/ is used to logicallyseparate the positional-only parameters from the rest of the parameters.If there is no/ in the function definition, there are no positional-onlyparameters.

Parameters following the/ may bepositional-or-keyword orkeyword-only.

Keyword-Only Arguments

To mark parameters askeyword-only, indicating the parameters must be passedby keyword argument, place an* in the arguments list just before the firstkeyword-only parameter.

Function Examples

Consider the following example function definitions paying close attention to themarkers/ and*:

>>>defstandard_arg(arg):...print(arg)...>>>defpos_only_arg(arg,/):...print(arg)...>>>defkwd_only_arg(*,arg):...print(arg)...>>>defcombined_example(pos_only,/,standard,*,kwd_only):...print(pos_only,standard,kwd_only)

The first function definitionstandard_arg, the most familiar form,places no restrictions on the calling convention and arguments may bepassed by position or keyword:

>>>standard_arg(2)2>>>standard_arg(arg=2)2

The second functionpos_only_arg is restricted to only use positionalparameters as there is a/ in the function definition:

>>>pos_only_arg(1)1>>>pos_only_arg(arg=1)Traceback (most recent call last):  File"<stdin>", line1, in<module>TypeError:pos_only_arg() got an unexpected keyword argument 'arg'

The third functionkwd_only_args only allows keyword arguments as indicatedby a* in the function definition:

>>>kwd_only_arg(3)Traceback (most recent call last):  File"<stdin>", line1, in<module>TypeError:kwd_only_arg() takes 0 positional arguments but 1 was given>>>kwd_only_arg(arg=3)3

And the last uses all three calling conventions in the same functiondefinition:

>>>combined_example(1,2,3)Traceback (most recent call last):  File"<stdin>", line1, in<module>TypeError:combined_example() takes 2 positional arguments but 3 were given>>>combined_example(1,2,kwd_only=3)1 2 3>>>combined_example(1,standard=2,kwd_only=3)1 2 3>>>combined_example(pos_only=1,standard=2,kwd_only=3)Traceback (most recent call last):  File"<stdin>", line1, in<module>TypeError:combined_example() got an unexpected keyword argument 'pos_only'

Recap

The use case will determine which parameters to use in the function definition:

deff(pos1,pos2,/,pos_or_kwd,*,kwd1,kwd2):

As guidance:

  • Use positional-only if names do not matter or have no meaning, and there areonly a few arguments which will always be passed in the same order.
  • Use keyword-only when names have meaning and the function definition ismore understandable by being explicit with names.

Reference Implementation

An initial implementation that passes the CPython test suite is available forevaluation[10].

The benefits of this implementations are speed of handling positional-onlyparameters, consistency with the implementation of keyword-only parameters (PEP3102), and a simpler implementation of all the tools and modules that would beimpacted by this change.

Rejected Ideas

Do Nothing

Always an option — the status quo. While this was considered, theaforementioned benefits are worth the addition to the language.

Decorators

It has been suggested on python-ideas[9] toprovide a decorator written in Python for this feature.

This approach has the benefit of not polluting function definition withadditional syntax. However, we have decided to reject this idea because:

  • It introduces an asymmetry with how parameter behavior is declared.
  • It makes it difficult for static analyzers and type checkers tosafely identify positional-only parameters. They would need to query the ASTfor the list of decorators and identify the correct one by name or with extraheuristics, while keyword-only parameters are exposeddirectly in the AST. In order for tools to correctly identifypositional-only parameters, they would need to execute the module to accessany metadata the decorator is setting.
  • Any error with the declaration will be reported only at runtime.
  • It may be more difficult to identify positional-only parameters in longfunction definitions, as it forces the user to count them to know which isthe last one that is impacted by the decorator.
  • The/ syntax has already been introduced for C functions. Thisinconsistency will make it more challenging to implement any tools andmodules that deal with this syntax — including but not limited to, theargument clinic, the inspect module and theast module.
  • The decorator implementation would likely impose a runtime performance cost,particularly when compared to adding support directly to the interpreter.

Per-Argument Marker

A per-argument marker is another language-intrinsic option. The approach addsa token to each of the parameters to indicate they are positional-only andrequires those parameters to be placed together. Example:

def(.arg1,.arg2,arg3):

Note the dot (i.e.,.) on.arg1 and.arg2. While this approachmay be easier to read, it has been rejected because/ as an explicit markeris congruent with* for keyword-only arguments and is less error-prone.

It should be noted that some libraries already use leading underscore[12] to conventionally indicate parameters as positional-only.

Using “__” as a Per-Argument Marker

Some libraries and applications (likemypy orjinja) use namesprepended with a double underscore (i.e.,__) as a convention to indicatepositional-only parameters. We have rejected the idea of introducing__ asa new syntax because:

  • It is a backwards-incompatible change.
  • It is not symmetric with how the keyword-only parameters are currentlydeclared.
  • Querying the AST for positional-only parameters would require checking thenormal arguments and inspecting their names, whereas keyword-only parametershave a property associated with them (FunctionDef.args.kwonlyargs).
  • Every parameter would need to be inspected to know when positional-onlyarguments end.
  • The marker is more verbose, forcing marking every positional-only parameter.
  • It clashes with other uses of the double underscore prefix like invoking namemangling in classes.

Group Positional-Only Parameters With Parentheses

Tuple parameter unpacking is a Python 2 feature which allows the use of a tupleas a parameter in a function definition. It allows a sequence argument to beunpacked automatically. An example is:

deffxn(a,(b,c),d):pass

Tuple argument unpacking was removed in Python 3 (PEP 3113). There has been aproposition to reuse this syntax to implement positional-only parameters. Wehave rejected this syntax for indicating positional only parameters for severalreasons:

  • The syntax is asymmetric with respect to how keyword-only parameters aredeclared.
  • Python 2 uses this syntax which could raise confusion regarding the behaviorof this syntax. This would be surprising to users porting Python 2 codebasesthat were using this feature.
  • This syntax is very similar to tuple literals. This can raise additionalconfusion because it can be confused with a tuple declaration.

After Separator Proposal

Marking positional-parameters after the/ was another idea considered.However, we were unable to find an approach which would modify the argumentsafter the marker. Otherwise, would force the parameters before the marker tobe positional-only as well. For example:

def(x,y,/,z):

If we define that/ marksz as positional-only, it would not bepossible to specifyx andy as keyword arguments. Finding a way towork around this limitation would add confusion given that at the momentkeyword arguments cannot be followed by positional arguments. Therefore,/would make both the preceding and following parameters positional-only.

Thanks

Credit for some of the content of this PEP is contained in Larry Hastings’sPEP 457.

Credit for the use of/ as the separator between positional-only andpositional-or-keyword parameters go to Guido van Rossum, in a proposal from2012.[8]

Credit for discussion about the simplification of the grammar goes toBraulio Valdivieso.

[1] (1,2)
https://docs.scipy.org/doc/numpy/reference/ufuncs.html#available-ufuncs
[2] (1,2)
https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gammaln.html
[3]
http://docs.python.org/3/library/stdtypes.html#dict
[4] (1,2)
http://docs.python.org/3/library/functions.html#func-range
[5]
http://docs.python.org/3/library/curses.html#curses.window.border
[6]
http://docs.python.org/3/library/os.html#os.sendfile
[7]
http://docs.python.org/3/library/curses.html#curses.window.addch
[8] (1,2,3)
Guido van Rossum, posting to python-ideas, March 2012:https://mail.python.org/pipermail/python-ideas/2012-March/014364.htmlandhttps://mail.python.org/pipermail/python-ideas/2012-March/014378.htmlandhttps://mail.python.org/pipermail/python-ideas/2012-March/014417.html
[9] (1,2)
https://mail.python.org/pipermail/python-ideas/2017-February/044888.html
[10]
https://github.com/pablogsal/cpython_positional_only
[11]
https://mail.python.org/pipermail/python-ideas/2016-January/037874.html
[12]
https://mail.python.org/pipermail/python-ideas/2018-September/053319.html
[13]
https://bugs.python.org/issue21314

Copyright

This document has been placed in the public domain.


Source:https://github.com/python/peps/blob/main/peps/pep-0570.rst

Last modified:2025-11-07 04:32:09 GMT


[8]ページ先頭

©2009-2025 Movatter.jp