pyc files not automatically compiled on import

Baz Walter bazwal at ftml.net
Sun Jul 26 12:22:53 EDT 2009


hello

i thought that python automatically compiled pyc files after a module is 
successfully imported. what could prevent this happening?


Python 2.6.1 (r261:67515, Apr 12 2009, 03:51:25)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import os
 >>> os.mkdir('/home/baz/tmp/foo')
 >>> os.chdir('/home/baz/tmp/foo')
 >>> f = open('foo.py', 'w')
 >>> f.write('print "hello world"\n')
 >>> f.close()
 >>> os.listdir('.')
['foo.py']
 >>> import foo
hello world
 >>> os.listdir('.') # why no pyc file?
['foo.py']
 >>> import py_compile
 >>> py_compile.compile('foo.py')
 >>> os.listdir('.')
['foo.py', 'foo.pyc']




More information about the Python-list mailing list