I have compiled this visible_code.py
file into .pyc
compiled byte code file, then I am running the function fun
from .pyc
file.
# visible_code.py
def fun():
print("Hello")
# convet to bytecode
import py_compile
py_compile.compile("visible_code.py", "secret_code.pyc")
Then I am deleting this file called visible_code.py
and trying to run the function fun
from secret_code.pyc
in main.py
file.
# main.py
from secret_code import fun
fun()
Everything works perfect until I change the python version, I get error regarding magic numbers. I have used this image from a different file structure.
Is there is any way that I can create this secret_code.pyc
file for all the python version or at least python3
. How to get rid of this magic numbers
error.