Are .pyc files portable?

Wubbulous at gmail.com Wubbulous at gmail.com
Fri Nov 7 22:01:31 EST 2008


Python compiles to bytecode, which means that pyc files can be
interpreted by any Python executable regardless of platform.

As for manual compilation to directories, the py_compile module is the
one you want. Here's an example program to plug in.

#test_compile.py#

import py_compile

print "hello"
py_compile.compile("test_compile.py", "C:\test_compile.pyc")


The manual page for py_compile.compile() can be found on this page:
http://www.python.org/doc/2.5.2/lib/module-pycompile.html

Hope that helps.
Cheers,
Wubbulous



More information about the Python-list mailing list