Problems compiling python
Florian Lindner
Florian.Lindner at xgm.de
Sun Jan 4 16:36:30 EST 2004
Erik Max Francis wrote:
> Florian Lindner wrote:
>
>> I want to compile that small python script:
> ...
>> bastet:/ # chmod u+x test.pyc
>> bastet:/ # ./test.pyc
>> ./test.pyc: line 1: syntax error near unexpected token `;'
>> '/test.pyc: line 1: `;ò
>> bastet:/ #
>>
>> What is wrong?
>
> A compiled Python file (.pyc) is not an executable. (Specifically, in
> the Unix world, it does not contain a bangpath.) Instead, just pass it
> as an argument to the Python interpreter:
>
> max at oxygen:~/tmp% cat > hello.py
> print "Hello, world!"
> ^D
> max at oxygen:~/tmp% python
> Python 2.3.3 (#1, Dec 22 2003, 23:44:26)
> [GCC 3.2.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import py_compile
>>>> py_compile.compile('hello.py')
>>>> ^D
> max at oxygen:~/tmp% ls hello.py*
> hello.py hello.pyc
> max at oxygen:~/tmp% rm hello.py
> max at oxygen:~/tmp% python hello.pyc
> Hello, world!
Can I run these scripts under another UID than the user executing them?
(SUID)
Thx,
Florian
More information about the Python-list
mailing list