Why don't I get a .pyc file?

Alex Martelli alex at magenta.com
Sat Aug 19 04:35:19 EDT 2000


"Rick Pasotto" <rickp at telocity.com> wrote in message
news:slrn8prjl1.21e.rickp at tc.telocity.com...
> I'm running linux, python 1.5.2.
>
> Isn't a .pyc file supposed to be automatically created whenever
> I run a .py file? Why don't I get one for the program I wrote?

The .pyc will be auto-generated on *import* from a .py file.

When you just _run_ a script, rather than importing it as a module,
the compiled bytecode is not auto-saved.  You can generate it
explicitly; or, move any reusable code to a module, import it
from your script, and whittle that script down to just a few calls
on the module -- the latter is often the best architecture.


Alex






More information about the Python-list mailing list