Is This Content Helpful?
We're glad to know this article was helpful.
Instructions provided describe how to lock a Python script so it cannot be edited. When scripts are going to be shared but the code needs to remain unchanged, compile the PY file into a PYC file. This ensures that the users are unable to make any changes to the existing code within the scripts. A PYC file is binary in nature and cannot be read directly.
Below is code that compiles a PY file into a PYC file.
PYC files run even if the PY files are not present.
script = "C:\\temp\\myscript.py"