0

I was looking for something in Djangos source code when I came upon the definition of django.forms.fields.Field.__init__():

class Field:
    def __init__(self, *, required=True, ...):

The method has more arguments, but I was surprised by the second argument, which is only the asterisk symbol. I had not seen this before. I could not find an explanation with a few quick google searches.

It is not a valid argument name, meaning I cannot use the passed value in print(*). It is also different from the *args and **kwargs arguments (I know how to use these 2).

Any explanations for this? Or any links where I can read about this usage?

Ralf
  • 16,086
  • 4
  • 44
  • 68
  • 1
    It prohibits any positional arguments to be passed in – Chris Jan 29 '19 at 13:19
  • 1
    Thanks; [this post](https://stackoverflow.com/a/39284225/9225671) (of which this question has been marked as duplicate) has answered my question. – Ralf Jan 29 '19 at 13:32

0 Answers0