title: Conflict between positional_or_keyword_parameters and var_positional_parameters?
body: <p>I just defined a function in the following when I learn about the knowledge about parameter:</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; def f1(a, b, /, c=0, *args,d, **kw):
      print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'd = ', d, 'kw =', kw)
  </code></pre>
  <p>And it seems to be running well in my first try:</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; f1(1,2,3,*[4,5,6],d=7,e=8)
  a = 1 b = 2 c = 3 args = (4, 5, 6) d =  7 kw = {'e': 8}
  </code></pre>
  <p>However, when I do modification about the argument for &quot;c&quot;, which is known as positional_or_keyword_parameters in python, the running results beyond my expectation.</p>
  <p>I trying to run:</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt;f1(1,2,c=3,*[4,5,6],d=7,e=8)
  &gt;&gt;&gt;f1(1,2,*[4,5,6],d=7,e=8)
  </code></pre>
  <p>In my expectation, the result will be:</p>
  <pre class="lang-py prettyprint-override"><code>a = 1 b = 2 c = 3 args = (4, 5, 6) d =  7 kw = {'e': 8}
  
  a = 1 b = 2 c = 0 args = (4, 5, 6) d =  7 kw = {'e': 8}
  </code></pre>
  <p>But the reality is:</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; f1(1,2,c=3,*[4,5,6],d=7,e=8)
  Traceback (most recent call last):
    File &quot;&lt;pyshell#20&gt;&quot;, line 1, in &lt;module&gt;
      f1(1,2,c=3,*[4,5,6],d=7,e=8)
  TypeError: f1() got multiple values for argument 'c'
  
  &gt;&gt;&gt; f1(1,2,*[4,5,6],d=7,e=8)
  a = 1 b = 2 c = 4 args = (5, 6) d =  7 kw = {'e': 8}
  </code></pre>
  <p>Then I look up the python documentation.  What surprised me was that there is not any example codes in python documentation like mine. I mean, the example codes like:</p>
  <pre class="lang-py prettyprint-override"><code>#the define:
      def f(a, b, /, c, d, *, e, f):
      def func(posonly1, posonly2, /, positional_or_keyword): ...
      def func(*args, **kwargs): ...
  </code></pre>
  <p>In these case,  the positional_or_keyword_parameters  and the var_positional_parameters cannot be present at the same time.</p>
  <p>Is that the truth?The syntax of python does not support that the positional_or_keyword_parameters  and the var_positional_parameters present at the same time？ If it does not, how can I achieve my expectations?</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; def f1(a, b, /, c=0, *args,d, **kw):
      print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'd = ', d, 'kw =', kw)
      
  #my expectations:
  &gt;&gt;&gt;f1(1,2,c=3,*[4,5,6],d=7,e=8)
  a = 1 b = 2 c = 3 args = (4, 5, 6) d =  7 kw = {'e': 8}
  &gt;&gt;&gt;
  
  &gt;&gt;&gt;f1(1,2,*[4,5,6],d=7,e=8)
  a = 1 b = 2 c = 0 args = (4, 5, 6) d =  7 kw = {'e': 8}
  &gt;&gt;&gt;
  </code></pre>
  <hr />
  <p>@Programmer:</p>
  <p>In your answer, you gave me advice on function definition:</p>
  <pre><code>def f1(a, b, /, d, *args, c=0, **kw):
  </code></pre>
  <p>I see that the parameter <em>d</em>  is defined without a default value, but <em>d</em> is opposite.  Let us talk about something more interesting about this.</p>
  <p>In my opinion,  the level of mastery of a syntax  depends on making it useful, not just using it correctly. I would like to do a split of your codes and ignore some elements, it will like like:</p>
  <pre class="lang-py prettyprint-override"><code>#define f1
  def f1(a, b, /, d=0):  #I prefer to do so, defining positional_or_keyword_parameters with default value
      
  #define f2
  def f2(*args,c) or def f2(*args,c=0) #define keyword_only_parameters with or without default value
  </code></pre>
  <p>Function definition like <em>f1</em>() is useful, think about the python function <em>range()</em>:</p>
  <pre class="lang-py prettyprint-override"><code>#I assume the definition of range() is liking the following
  def range(start, /, stop=None, step=1):  #the dedault value is frequently used
      if stop is None:   #use a few tips
          stop = start
          start = 0
      ...    
  #I defined the positional_or_keyword_parameters(just &quot;stop&quot; and &quot;step&quot;) with default value
  #Therefore, I can generate the following instances:
  
  range(10)                 #when I don't need the &quot;stop&quot; and &quot;step&quot;, codes can be simple
  range(0,10)               #I need &quot;start&quot; and &quot;stop&quot; but not &quot;step&quot;, I can still ignore the value of &quot;step&quot;
  range(0,10,1)             #I need all of them, however, I can still avoid complex syntax checks
  
  #In short, this parameters definiton() make us more focusing on the polymorphism of functions and generating an instance by a very simple way, rather than doing complex syntax checks again and again
  
  #Imagine this...
  def range(start,/,stop=None,step): # define positional_or_keyword_parameters without default value
      ...
      
  &gt;&gt;&gt;range(10,step=1)     #I have to write the stupid &quot;step=1&quot; again and again
  &gt;&gt;&gt;range(5,step=1)
  &gt;&gt;&gt;range(3,step=1)
  
  &gt;&gt;&gt;range(1,10,1)        #I have to write the stupid &quot;1&quot; again and again
  &gt;&gt;&gt;range(2,5,1)
  &gt;&gt;&gt;range(3,6,1)
  </code></pre>
  <p>The situation is reversed when I define the function like <em>f2()</em>,  think about the python function <em>max()</em>:</p>
  <pre class="lang-py prettyprint-override"><code>#I assume the definition of max() is liking the following
  def max(*args,key) or def max(*args,key=abs) :
      ...
  #They are all useful
  #In this case, max() must receive var_positional_parameters at first, and then use keyword_only_parameters(&quot;key&quot; in this case) to achieve the polymorphism of functions. If the keyword_only_parameters without default value, it will make a serious situations that user of max() must explicitly what he/she do with the max(), and still no loss the polymorphism of functions. Relativily, the case  of keyword_only_parameters with default value do more convenience but less strictness.
  
  #example codes
  max(1,2,3,4,5,6,7,8,9,10,key=abs)    # *args is so long...  the length of &quot;key=abs&quot; is easy to accept
  max(*list)                           # It's convenient
  </code></pre>
  <p>Back to the main topic, my question about the definition like:</p>
  <pre class="lang-py prettyprint-override"><code>def f1(a, b, /, c=0, *args,d, **kw):
      ...
      
  #  let us ignore irrelevant elements, it will be:
  def f1(/, c=0, *args,d):
  </code></pre>
  <p>In fact, I loss of interest about it in few hours. The reason is that I can't figure out why I have to define a function like it. Its syntax is correct , but useless at the same time. At least I can't think of any use for it.</p>
  <p>A useless syntax ...</p>
  <p>Maybe my question is really boring...</p>