compiling python code

Discussion in 'Python' started by Gabriele *Darkbard* Farina, May 26, 2005.

  1. Hi,

    I have a python file inside a zip file. I'd like to compile it and add
    the resulting .pyc file into the zip. I tryed reading the source and
    compiling it using compile(), but I don't know how to write .pyc file.
    Can someone give me some help?

    bye,
    gabriele
     
    Gabriele *Darkbard* Farina, May 26, 2005
    #1
    1. Advertising

  2. Gabriele *Darkbard* Farina wrote:

    > I have a python file inside a zip file. I'd like to compile it and add
    > the resulting .pyc file into the zip. I tryed reading the source and
    > compiling it using compile(), but I don't know how to write .pyc file.
    > Can someone give me some help?


    a PYC file consists of a 4-byte header (from imp.get_magic()), an 4-byte
    timestamp (seconds since epoch as a 32-bit little endian integer), followed
    by the marshalled code block.

    see the source code for the py_compile module in the standard library for
    some sample code -- or use the module itself to do the work for you:

    http://effbot.org/librarybook/py-compile.htm

    </F>
     
    Fredrik Lundh, May 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carsten Heesch

    Need help: Compiling Python-Code

    Carsten Heesch, Jul 15, 2003, in forum: Python
    Replies:
    0
    Views:
    304
    Carsten Heesch
    Jul 15, 2003
  2. Thomas Buschhardt

    Re: Need help: Compiling Python-Code

    Thomas Buschhardt, Jul 15, 2003, in forum: Python
    Replies:
    2
    Views:
    795
    Carsten Heesch
    Jul 15, 2003
  3. Garrett Cooper
    Replies:
    0
    Views:
    586
    Garrett Cooper
    Feb 24, 2009
  4. Garrett Cooper
    Replies:
    0
    Views:
    518
    Garrett Cooper
    Feb 24, 2009
  5. Lon Baker
    Replies:
    1
    Views:
    236
    Csaba Henk
    Mar 21, 2005
Loading...

Share This Page