Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > compiling python code

Reply
Thread Tools

compiling python code

 
 
Gabriele *Darkbard* Farina
Guest
Posts: n/a
 
      05-26-2005
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
 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      05-26-2005
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>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Cross-compiling error when compiling 2.6.1... Garrett Cooper Python 0 02-24-2009 09:47 PM
Cross-compiling error when compiling 2.6.1... Garrett Cooper Python 0 02-24-2009 08:55 PM
Compiling when libedit is in path Is there a trick to compiling Ruby when libedit must exist in the search path? Can you statically link to readline 5.0 in some manner? -- Lon Baker Lon Baker Ruby 1 03-21-2005 08:57 AM
Re: Need help: Compiling Python-Code Thomas Buschhardt Python 2 07-15-2003 10:10 PM
Need help: Compiling Python-Code Carsten Heesch Python 0 07-15-2003 07:48 AM



Advertisments