Sep-11-2017, 01:24 AM
i think i get it now (after reading the PEP).
in def's function prototype, you can have an argument like
also, there is no means i am aware of that provides for a named argument that has no default value, and as a result of that must be provided in a call as a
in def's function prototype, you can have an argument like
foo='bar'
at a specific position. when calling that function, you can provide a value either in that same position without a name or in any ending position by name. all named values must follow all positioned values (a positioned value may not follow a named value ... after named values, positions are ambiguous). what the *
argument does is change the argument list from that point on so that their defined positions do not have a positional meaning ... to provide a value, the call must provide it as name=value
(what are typically called "options" even if we make them mandatory).Output:lt1/forums /home/forums 3> py3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(a,b,*,c=1):
... return a,b,c
...
>>> f(1,2,3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() takes 2 positional arguments but 3 were given
>>> f(1,2,c=3)
(1, 2, 3)
>>>
lt1/forums /home/forums 4>
this does not provide for a means to have an argument be position-only and have a default value if not provided. that is already provided for as variable argument lists.also, there is no means i am aware of that provides for a named argument that has no default value, and as a result of that must be provided in a call as a
name=value
form. i propose enabling this by allowing the argument prototype to have arguments to do this in the form name=
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.