title: How to run a python script without specifying the file extension (cross platform solution)?
body: <p>Let's say that we have a Python script <code>do.py</code> and we want to be able to call it without extension, like <code>do</code> or <code>./do</code>. </p>
  
  <p>If we rename the file from <code>do.py</code> to <code>do</code> and assure we have a valid shebang line it will work for all platforms but Windows. On Windows there is no way of executing file without extension.</p>
  
  <p>On Windows, if we keep the original file extension we'll be able to call the script without the full name because the Python installer registers the <code>.py</code> extension as an executable one.</p>
  
  <p>It looks that we need to deliver the same script under two different names in order to be call it on Windows and non-Windows environments. I really do not like this and I'm looking for a solution without this redundancy.</p>
  
  <p>Another common approach on this is to add a <code>do.cmd</code> wrapper batch file that is calling the original <code>do.py</code> file. This has at least one major issue: it does <strong>break the Ctrl+C / Ctrl+Break</strong> because there is no way to prevent <code>cmd.exe</code> from prompting you with <a href="https://stackoverflow.com/questions/1234571/how-can-i-suppress-the-terminate-batch-job-in-cmd-exe"><strong>Terminate batch job? (Y/N)</strong> message.</a></p>
  
  <p>If we are about to use a wrapper we need to be sure that:</p>
  
  <ul>
  <li>return the errorcode (errorlevel) returned by the original script</li>
  <li>it will not change the environment</li>
  <li>it will reuse the same console (no new windows)</li>
  <li>doesn't interfere with STDOUT, STDIN or STDERR</li>
  <li>be friendly with Ctrl-C (no prompts)</li>
  </ul>
  
  <p>I suppose the optimal solution is still to use a wrapper. Batch won't work, native executable would add a lot of complexity so probably a wrapper wrote in python itself would do.</p>