11

I was browsing through this file of code and then I found this class:

class StreamPlaylistEntry(BasePlaylistEntry):
def __init__(self, playlist, url, title, *, destination=None, **meta):
    super().__init__()

I know that an asterisk in front of a parameter means it's a list of an arbitrary number of arguments, but what does the asterisk by itself mean?

Retronix
  • 216
  • 2
  • 13

1 Answers1

16

It means all arguments afterwards are keyword-only. As said in the official glossary under the word parameter:

  • 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): ...
    
Graipher
  • 6,891
  • 27
  • 47