How to compile a Python program using the py_compile module
gd.py
a,b=10,20 (a,b)=(b,a) print(a,b)
Output
godarda@gd:~$ ls gd.csv Desktop Downloads Pictures Templates gd.py Documents Music Public Videos godarda@gd:~$ python3 -m py_compile gd.py godarda@gd:~$ ls gd.csv Desktop Downloads Pictures __pycache__ Videos gd.py Documents Music Public Templates godarda@gd:~$ cd __pycache__/ godarda@gd:~/__pycache__$ ls gd.cpython-312.pyc godarda@gd:~/__pycache__$ python3 gd.cpython-312.pyc 20 10 godarda@gd:~/__pycache__$ cat gd.cpython-312.pyc � �!��*�d\ZZeecZZeee�y))� �N)�a�b�print���gd.py<module>r s"�� ���!����1��a�� godarda@gd:~/__pycache__$
Comments and Reactions
What Next?
How to view the byte code instructions using the dis module
Python program to perform the arithmetic operations
Python program to perform the relational operations
Advertisement