Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what is ,*, ?
#10
(Sep-09-2017, 12:26 PM)syogun Wrote: This '*' specifies an argument that can be supplied only by keyword.
Quote:keyword-only: specifies an argument that can be supplied only by keyword. Keyword-only parameters can be defined by including a single var-positional parameter or bare * in the parameter list of the function definition before them, for example kw_only1 and kw_only2 in the following:
def func(arg, *, kw_only1, kw_only2): ...
 
so, where ,*, is not used, the documentation is saying that these arguments, or those before the ,*,, can be provided by either a named option or be unnamed in the position shown?

so, is this how to code a function prototype to do that?

def f(positional, either_way_with_default_value='foo', *, only_as_a_named_option='bar'): ...
???

so how can a definition of an argument specifying that it can be given either way define the difference between a required argument and one that is not required (e.g. calling f() above with just one positional  argument)?
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