[Tutor] HELP- Regarding working with python
Steven D'Aprano
steve at pearwood.info
Mon Jan 28 09:20:30 CET 2013
On 28/01/13 18:26, Gayathri S wrote:
> Hi all..!
> wanna know how to compile python script in python command line,
> and is there any need for setting path for python like JAVA? whats the
> difference between .py file and .pyc file?
Python is a byte-code compiled language, like Java many years ago. Normally to compile a python module, you just import it from within Python.
That is not very convenient for scripts, so from the shell (bash, command.com, cmd.exe, or similar) you can run
python -m compileall NAME NAME ...
to compile scripts.
You do not necessarily need to set the PYTHONPATH, but you can if you need to.
.py files are source code. .pyc are compiled byte code. .pyo are compiled byte code with optimization turned on. Don't get too excited, the standard Python optimization doesn't do very much.
--
Steven
More information about the Tutor
mailing list