title: How to change the order of function's argumnets
body: <p>*edited</p>
  
  <p>What I want to is as below</p>
  
  <pre><code>def func(x1, x2, ... , xi, ..., xn):
     doing something
     return
  
  def F(func, i):
     def newFunc(xi, x2, ..., x1, ..., xn):
        return func(x1, x2, ..., xi, ..., xn)
     doing something with newFunc
  
  </code></pre>
  
  <p>where n is unknown(arbitrary)
  *</p>
  
  <p>I am not good at English and I am a beginner of python, so please understand. 
  I make a function that takes a function and an integer.
  Let me call the function what I make as <code>F</code>, the function that is an argument of <code>F</code> as <code>func</code>, and the integer as <code>i</code>.
  In the <code>F</code>, a new function which first argument and <code>i</code>-th argument of <code>func</code> are switched is made. (I'll do something with the new function in <code>F</code>.)
  If I exactly know the arguments of <code>func</code>, I can make the <code>F</code> as below.
  But If I don't know the number of arguments, how can I make <code>F</code>?</p>
  
  <pre><code>def F(func, i=1):
      def newFunc(u, x, e):
          return func(x, u, e)
  
      ...Do something with newFunction...
  </code></pre>
  
  <p>I tried <code>signature</code>, but the return of <code>signature</code> can't be switched.
  And I tried <code>.__code__.co_varnames</code> as below</p>
  
  <pre><code>def F(func, i):
      arg_num = func.__code__.co_argcount
      arg_pre = list(func.__code__.co_varnames)[:arg_num]
      arg_next = list(func.__code__.co_varnames)[:arg_num]
      arg_next[0], arg_next[i] = arg_next[i], arg_next[0]
      def newFunc(arg_next):
          return func(arg_pre)
  </code></pre>
  
  <p>In this case, however, <code>return func(arg_pre)</code> recognizes <code>arg_pre</code> as 1 positional argument.</p>
  
  <p>I hope you understand what I want to mean. Thank you.</p>