Howto Generate pyc from a Python Program
In this post, I will give you an example to demonstrates how to generate a .pyc from compiling a python program.
What is the .pyc? A .pyc file is a compiled python bytecode file, you can visit how do I create a pyc file for more information.
Fist, I write a python script named hello.py as following:
1 | #!/usr/bin/python |
Then use chmod command to change its file privilege.
1 | $ chmod a+x hello.py |
Now, edit a python script as pycoder.py.
1 | #!/usr/bin/python |
Then, do the same thing as hello.py.
1 | $ chmod a+x pycoder.py |
At last, please run pycoder.py script, and a pyc bytecode hello.pyc is generated.
1 | $ ./pycoder.py |
Enter Your File Name: hello.py
.pyc of the python script hello.py is generated.