Am Fri, 19 Dec 2008 09:01:24 -0500 schrieb "Emad Nawfal (عماد نوفل)" <emadnaw...@gmail.com>:
You are not supposed to compile the main script. pyc files are automatically generated when you import the py file (but not execute it), if you are allowed to write them beside the py file. When a pyc file exists, and it's newer than the py file, python will import the py file from the pyc file, thus saving on parsing the py file. In effect the pyc file is nothing more than a file cache for the parsed and bytecompiled version of the py file. Andreas > Hi Tutors, > #! /usr/bin/env python > print "Hello Tutors" > > I have this script saved as hello.py. Why can I execute it, but not > the compiled version? or am I doing something wrong? Just curious. > Any help appreciated. > For example : > > > e...@emad-laptop:~/Desktop/Programming/Haskell$ chmod +x hello.py > e...@emad-laptop:~/Desktop/Programming/Haskell$ ./hello.py > Hello Tutors > > Now I compile it in Python: > >>> import py_compile > >>> py_compile.compile("hello.py") > >>> > e...@emad-laptop:~/Desktop/Programming/Haskell$ chmod +x hello.pyc > > e...@emad-laptop:~/Desktop/Programming/Haskell$ ./hello.pyc > : command not found: � > ./hello.pyc: line 2: syntax error near unexpected token `(' > ./hello.pyc: line 2: `�k...@s dGHdS(s > Hello > TutorsN((((hello.py<module>s' > e...@emad-laptop:~/Desktop/Programming/Haskell$ > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor