title: How to run python script inside vim?
body: <p>I know we can run <code>a.py</code> in vim using commands:</p>
  
  <pre><code>:! python a.py    " method 1
  :! python %       " method 2
  </code></pre>
  
  <p>We can also set key binding to run python script as:</p>
  
  <pre><code>autocmd! FileType python nmap ,r :!clear; python %&lt;CR&gt;
  </code></pre>
  
  <p>Now the problem is if we have to pass the arguments, I tried to create a command like this:  </p>
  
  <pre><code>command py !python %   " This does not work!!
  </code></pre>
  
  <p><strong>Required</strong>:<br>
  <code>:py arg1 arg2</code> should run python script with arguments arg1 and arg2, i.e. <code>python a.py arg1 arg2</code></p>
  
  <p>Example python script:</p>
  
  <pre><code>import sys
  print(sys.argv[1])
  print(sys.argv[2])
  </code></pre>
  
  <p>I am using vim in Macbook Pro.</p>
  
  <pre><code>$ vim --version
  VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)
  Included patches: 1-503, 505-680, 682-1283
  Compiled by root@apple.com
  </code></pre>