How to compile a python script to *.pyo

danny at iamlearning.com danny at iamlearning.com
Wed Apr 2 16:39:37 EST 2003


> Philippe Lafoucrière wrote:
>>
>> danny at iamlearning.com wrote:
>>
>> > I'm new on this, please bear with we.
>> >
>> > Let's say I have this script:
>> >
>> > --------------------------
>> > #!/usr/bin/env python
>> > x = 'Hello Python'
>> >
>> > print x,
>> >
>> > --------------------------
>> >
>> > How can I compile this script to *.pyo?
>> >
>> > Thanks in advance,
>> >
>> > Danny
>>
>> python -O yourscript.py
>
> Generally this doesn't work.  You have to import
> a module (or use other techniques) for it to be compiled.
> Python does not store a .pyc or .pyo file for the main
> module, perhaps surprisingly.
>
> -Peter
> --
> http://mail.python.org/mailman/listinfo/python-list


What are other techniques I can use?
I want my users run *.pyo or *.pyc files instead of *.py.

-Danny








More information about the Python-list mailing list