Dave Crouse wrote:
I got the same thing with idle, but when running as a script, it's not
the same, it errors. I tried it on Windows and Linux.
-------------------------------------------
[da...@arch64 Python]$ less test.py
#/usr/bin/python3
print ('The \"This is a test \" {')
[da...@arch64 Python]$ sh test.py
test.py: line 3: syntax error near unexpected token `'The \"This is a
test \" {''
test.py: line 3: `print ('The \"This is a test \" {')'
Maybe I'm missing something, but this error is because you're running a
Python script using the Linux shell, probably bash as the interpreter
instead of Python. Also, if you're running it on its own as a script,
you'd want to add a '!' after the '#' - otherwise it's just a comment,
not setting the interpreter.
To run a Python file as a script, you'd need to do:
[da...@arch64 Python]$ python3 test.py
(or just ./test.py if it's executable and the interpreter is set using
'#!/usr/bin/python3')
When I do that, it works for me just fine without doubling the '{'
Cheers,
Vern
--
This time for sure!
-Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor