title: How can I create a locked python file that can be executed?
body: <p>This question is just out of curiosity: Is there any way to create a python file (<strong>.py</strong>) which is <em>locked</em> but <em>executable</em>?</p>
  <p>Meaning if I try to access (open) it, it will ask for a key so that the source code can't be seen or edited. But if I execute it through a terminal, it can be run. For e.g.:</p>
  <pre><code>&gt;&gt;&gt; python locked_file.py
  Type an integer: 
  </code></pre>
  <p>PS: Just for clarification. My question is <strong>not</strong> about <strong>converting</strong> a <strong>.py</strong> file to an <strong>executable (.exe)</strong> or <strong>.pyc</strong> or <strong>encrypted</strong> or <strong>obfuscated file</strong>.</p>