title: How to save python command line arguments to a log file?
body: <p>I have a python script <code>test.py</code>, which has dozens of arguments/flags: <code>--flag1</code>, <code>--flag2</code>, ...,<code>--flagn</code>. In order to run it, I do a command like </p>
  
  <pre><code>python test.py --flag1 value1 --flag3 value3 --flag8 value8
  </code></pre>
  
  <p>In this case, I would like to save the exact same input line to a log file. In the above example, I would like to have a <code>log.txt</code> that contains only one line: </p>
  
  <pre><code>python test.py --flag1 value1 --flag3 value3 --flag8 value8
  </code></pre>
  
  <p>Because this script has dozens of flags, and some of them are defaulted to some values, I only care about what the user's input is, and I don't need any information about default values for other arguments that a user doesn't specify directly. </p>
  
  <p>How can I create a log file like this that contains the exact same line the user typed?</p>