Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what is ,*, ?
#22
i think i get it now (after reading the PEP).

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.
Reply


Messages In This Thread
what is ,*, ? - by Skaperen - Sep-09-2017, 01:45 AM
RE: what is ,*, ? - by metulburr - Sep-09-2017, 01:57 AM
RE: what is ,*, ? - by ichabod801 - Sep-09-2017, 02:27 AM
RE: what is ,*, ? - by Skaperen - Sep-09-2017, 04:02 AM
RE: what is ,*, ? - by hbknjr - Sep-09-2017, 07:24 AM
RE: what is ,*, ? - by syogun - Sep-09-2017, 12:26 PM
RE: what is ,*, ? - by Skaperen - Sep-10-2017, 12:23 AM
RE: what is ,*, ? - by metulburr - Sep-09-2017, 10:00 PM
RE: what is ,*, ? - by dvs1 - Sep-09-2017, 10:54 PM
RE: what is ,*, ? - by Larz60+ - Sep-09-2017, 11:03 PM
RE: what is ,*, ? - by Skaperen - Sep-10-2017, 02:56 AM
RE: what is ,*, ? - by snippsat - Sep-10-2017, 12:39 AM
RE: what is ,*, ? - by snippsat - Sep-10-2017, 01:00 AM
RE: what is ,*, ? - by Larz60+ - Sep-10-2017, 01:50 AM
RE: what is ,*, ? - by ichabod801 - Sep-10-2017, 02:09 AM
RE: what is ,*, ? - by syogun - Sep-10-2017, 02:15 AM
RE: what is ,*, ? - by metulburr - Sep-10-2017, 04:05 AM
RE: what is ,*, ? - by syogun - Sep-10-2017, 04:40 AM
RE: what is ,*, ? - by ichabod801 - Sep-10-2017, 01:03 PM
RE: what is ,*, ? - by metulburr - Sep-10-2017, 10:35 PM
RE: what is ,*, ? - by nilamo - Sep-10-2017, 11:20 PM
RE: what is ,*, ? - by Skaperen - Sep-11-2017, 01:24 AM
RE: what is ,*, ? - by Skaperen - Sep-11-2017, 03:19 AM
RE: what is ,*, ? - by Sagar - Sep-11-2017, 09:13 AM
RE: what is ,*, ? - by Skaperen - Sep-13-2017, 01:07 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020