Compiled Byte code

Fredrik Lundh fredrik at pythonware.com
Wed Oct 13 09:59:18 EDT 2004


"Soumitri" wrote:

> Is there a dependency of version or platform for running a snippet of
> python compiled code? I have a .pyc (possibly created on a *nix box)
> that was created off ver 1.5.2 and returns a "Bad Magic Number in .pyc
> file" error when i run a box with XP and Python 2.3.

the byte code is changed from time to time.  you can use imp.get_magic()
to get an identifier for the current format; any interpreter that has the same
"magic" can run your code.

    http://docs.python.org/lib/module-imp.html

for some ideas on how to use get_magic() in your code, see:

    http://mail.python.org/pipermail/python-list/2003-November/196230.html

</F> 






More information about the Python-list mailing list