Precimpiling *.py to *.pyc.

David Porter jcm at bigskytel.com
Tue Sep 26 15:19:45 EDT 2000


* Thaddeus L. Olczyk <olczyk at interaccess.com>:
> Is there any way of compiling all the *.py to *.pyc files?

Since they are compiled when imported as libraries, it would be easy to have
a script import one after the other. E.G.,

import os
for x in os.listdir('.'):
    if x[-3:] == '.py':
        exec('import '+x[0:-3])
	exec('del '+x[0:-3])
	

I don't know whether the last line is important or not.

  David
  
  




More information about the Python-list mailing list