4

I recently worked on several projects and see a new syntax code, a method that get a * arguments(i know about *args and **kwargs)

for an example in django 2.0.4:

class DataListView(ListView):
    ...
    def get_context_data(self, *, object_list=None, **kwargs): # * argument without suffix
        return super().get_context_data(object_list, **kwargs)

and Question: what is meaning of * arguments in python function/method?

hadi
  • 1,680
  • 1
  • 15
  • 29

1 Answers1

3

It's so that object_list must be a named argument. All positional arguments will be captured by * and ignored.

This was added in python 3.0 and is described in PEP 3132 -- Extended Iterable Unpacking

Håken Lid
  • 21,116
  • 9
  • 46
  • 63