I noticed importing an executable Python file saves a *.py[co] file, as expected, but that file also is marked executable. Randomly, I wondered if I could execute this file directly, and it worked!
Duplicate:
$ touch empty.py; chmod u+x empty.py
$ python -c 'import empty'
$ ls -og empty.py
-rwxr----- 1 0 2009-11-21 15:25 empty.py*
-rwxr----- 1 95 2009-11-21 15:25 empty.pyc*
$ ./empty.pyc
(There isn't any output, as expected.)
How? Is my system, Ubuntu 9.04, doing something special, or am I forgetting something on how Linux works in general?
$ python --version
Python 2.6.2
$ hd empty.pyc
00000000 d1 f2 0d 0a ae 41 08 4b 63 00 00 00 00 00 00 00 |.....A.Kc.......|
00000010 00 01 00 00 00 40 00 00 00 73 04 00 00 00 64 00 |.....@...s....d.|
00000020 00 53 28 01 00 00 00 4e 28 00 00 00 00 28 00 00 |.S(....N(....(..|
00000030 00 00 28 00 00 00 00 28 00 00 00 00 73 08 00 00 |..(....(....s...|
00000040 00 65 6d 70 74 79 2e 70 79 74 08 00 00 00 3c 6d |.empty.pyt....<m|
00000050 6f 64 75 6c 65 3e 01 00 00 00 73 00 00 00 00 |odule>....s....|
0000005f