How can I create a locked python file that can be executed?

Viewed 68

This question is just out of curiosity: Is there any way to create a python file (.py) which is locked but executable?

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.:

>>> python locked_file.py
Type an integer: 

PS: Just for clarification. My question is not about converting a .py file to an executable (.exe) or .pyc or encrypted or obfuscated file.

0 Answers
Related