Compiling main script into .pyc

Grant Edwards invalid at invalid.invalid
Fri Jan 17 15:12:56 EST 2014


On 2014-01-17, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> On Thu, 16 Jan 2014 23:43:02 -0500, Dave Angel wrote:

> [steve at ando ~]$ cat sample.py
> print("Hello!")
>
> [steve at ando ~]$ ls sample.pyc
> ls: sample.pyc: No such file or directory
> [steve at ando ~]$ python -m compileall sample.py
> Compiling sample.py ...
> [steve at ando ~]$ ls sample.p*
> sample.py  sample.pyc
> [steve at ando ~]$ python sample.pyc
> Hello!

Cool!  Now I can distribute my application as a pre-compiled "binary"
just like I do for <insert language/platform/OS here>.

[That was meant ironically, BTW]

-- 
Grant Edwards               grant.b.edwards        Yow! I want EARS!  I want
                                  at               two ROUND BLACK EARS
                              gmail.com            to make me feel warm
                                                   'n secure!!



More information about the Python-list mailing list