Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what is ,*, ?
#5
I always thought * was for unpacking, but that's surely not the case here.

I looked at sorted function code didn't find any use of *(except for the pointers in C).

May be it is to differentiate positional or keyword arguments. func(positional args,*, keyword args)

may be to represent that after ,*, no positional argument could be there.

Just a theory, let me know if you find a counter-example.

Ok so i tried to use ,*, in function defination and all it did is convert the argument on right to keyword argument.

>>> def myFunction(a, *, b):
...     return a+b
...
>>> myFunction(3,5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: myFunction() takes 1 positional argument but 2 were given

>>> myFunction(3,b=5)
8
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