title: Debug a python script with arguments from terminal
body: <p>I have a python script that takes input arguments and runs in response to the following command in terminal (bash, Mac OSX).</p>
  
  <pre><code>python test.py arg1 arg2
  </code></pre>
  
  <p>Is there a good way to run the same script in debug mode without editing the code to include <code>import pdb</code> and <code>pdb.set_trace()</code>?</p>
  
  <p>For example, if I'm using iPython console, I can do this by the following:</p>
  
  <pre><code>%run -d test.py arg1 arg2
  </code></pre>
  
  <p>This is pretty straightforward, isn't it? To achieve the same thing in terminal, I thought the following might work, but it did not:</p>
  
  <pre><code>python -c "import pdb; import sys; sys.argv = ['test.py', arg1, arg2];pdb.run('test.py')"
  </code></pre>
  
  <p>The code ran with the arguments, but not in <code>pdb</code>'s debugging mode. Is it just hard to do and I should stick with <code>pdb.set_trace</code> or iPython's <code>%run -d</code>?</p>