.pyc files
Rick Holbert
holbertr at dma.org
Tue Jan 28 15:22:18 EST 2003
Peter Hansen wrote:
> Newt wrote:
>>
>> Silly question:
>>
>> From a command line, how do I create pyc files? I know I can do it from
>> within IDLE, but I want to use a different editor (for other languages).
>
> This just worked for compiling file "logger.py" in my temp folder:
>
> python -c "import py_compile as p; p.compile('c:/temp/logger.py')"
>
> -Peter
This should work nicely in a shell/bat script:
#!/bin/sh
# A quick hack to compile python source into .pyc and .pyo files
#
# Usage: ./py2byte source_file.py
#
# Rick Holbert, 28 Jan 2003
# To convert to MS DOS .bat file, replace $1 with %1
python -c "import py_compile; py_compile.compile(r'$1')"
python -O -c "import py_compile; py_compile.compile(r'$1')"
More information about the Python-list
mailing list