How to use *.py modules instead of *.pyc?

D

dsblizzard

How to use *.py modules instead of *.pyc or automatically recompile
all modules each time I change *.py files?
Thank you in advance.
 
C

Chris Rebert

How to use *.py modules instead of *.pyc or automatically recompile
all modules each time I change *.py files?

IIRC, you shouldn't need to worry about this. Python checks the
modification times on the .py and .pyc files and if the .pyc is older,
it regenerates the .pyc from the .py; thus ensuring that the latest
version of the source file is always used.
What led you to conclude otherwise?

Cheers,
Chris
 
J

John Machin

How to use *.py modules instead of *.pyc or automatically recompile
all modules each time I change *.py files?

You don't need to do anything special. If, when you import foo,
foo.pyc is outdated by changes to the foo.py that is in the same
directory, then foo.py will be compiled to a new foo.pyc -- otherwise
compilation is unnecessary and the existing foo.pyc will be used.

If you think you have a problem, it could be caused by foo.pyc being
in a directory that is in sys.path but you are editing a foo.py that
is not in sys.path.

HTH,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top