**NEWBIE - QUESTION**

Jay Dorsey jay at jaydorsey.com
Tue Oct 28 12:15:08 EST 2003


Staven Bruce wrote:
> I am new to Python and am trying to use the Python-2.3.2-1Interperter on
> Windows. I have a .py file and I am trying to compile it into a .pyc file.
> When I began experimenting with Python, I could have sworn that opening the
> .py file in IDLE, modifying it, and then saving it would automatically
> create the corresponding .pyc file. But this is not working. 

I believe you have to *run* the file to get it to compile, not just save it.

> I have checked the FAQ's and the Python Help pages, but I believe I am
> somewhat dense. If I try to call 'compileall file.py', the syntax is
> invalid. If I try to call 'compile file.py' I also receive a syntax error. I
> know I am missing something rather basic here, but if anyone could
> point/shove me in the right direction I would appreciate it. 

This should work as well:

 >>> from compileall import py_compile
 >>> py_compile.compile("myfile.py")

Jay






More information about the Python-list mailing list