How do I associate python with py files in bash
<p>A common question is "how do I make <em>my</em> python script executable without explicitly calling python on the command line?", and the answer is <code>chmod +x</code> it and then add <code>#!/usr/bin/env python</code> at the start of the script.</p>

<p>That is <em>not</em> the question I'm asking.</p>

<p>What I would like to do is tell bash, or python, or whatever is responsible for file-handling to treat all .py files that have the execute bit set as if they have the shebang at the beginning whether or not they actually do.</p>

<p>I understand that in Windows this can be done, and apparently in Gnome for the use-case where you double-click on a .py script from the GUI. I could have sworn I remembered hearing about an equivalent way of specifying a handler from the shell.</p>

<p>Why I want to know how to do this (if it's actually possible):</p>

<ul>
<li>Not every system uses shebang and I don't want to clutter up files in a cross-platform project with it.</li>
<li>If I'm submitting a patch to a project I don't own, it's slightly obnoxious for me to put stuff unrelated to the patch into it for my own convenience.</li>
</ul>

<p>Thanks.</p>