Why the file mode of .pyc files has x?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Sep 26 09:10:47 EDT 2009


On Sat, 26 Sep 2009 06:57:52 -0500, Peng Yu wrote:

> Hi,
> 
> It is strange that the file mode of .pyc files are changed to executable
> (x mode) after the corresponding .py files have been run.

Are you sure? They don't on my system.


[steve at sylar test]$ ls -l
total 8
-rw-rw-r-- 1 steve steve 6 2009-09-26 23:06 test.py
[steve at sylar test]$ python2.6 test.py
[steve at sylar test]$ ls -l
total 8
-rw-rw-r-- 1 steve steve 6 2009-09-26 23:06 test.py


Running a .py file does not generally create a .pyc file. Normally you 
have to import it:

[steve at sylar test]$ python2.6
Python 2.6.1 (r261:67515, Dec 24 2008, 00:33:13)
[GCC 4.1.2 20070502 (Red Hat 4.1.2-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
>>> exit()
[steve at sylar test]$ ls -l
total 16
-rw-rw-r-- 1 steve steve  6 2009-09-26 23:06 test.py
-rw-rw-r-- 1 steve steve 94 2009-09-26 23:08 test.pyc


Have you checked the umask of your system?



-- 
Steven



More information about the Python-list mailing list