title: In Python, can I specify a function argument's default in terms of other arguments?
body: <p>Suppose I have a python function that takes two arguments, but I want the second arg to be optional, with the default being whatever was passed as the first argument. So, I want to do something like this:</p>
  
  <pre><code>def myfunc(arg1, arg2=arg1):
      print (arg1, arg2)
  </code></pre>
  
  <p>Except that doesn't work. The only workaround I can think of is this:</p>
  
  <pre><code>def myfunc(arg1, arg2=None):
      if arg2 is None:
          arg2 = arg1
      print (arg1, arg2)
  </code></pre>
  
  <p>Is there a better way to do this?</p>