the error is in one of the lines you did not copy here....
because this works without problems:
<<BEGIN-of script>>
#!/usr/bin/python
Most probably, your /usr/bin/python program is python version 2, and not
python version 3
Try the same program with /usr/bin/python3. And also try the interactive
mode with the same program and I think you will see the same phenomenon.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
https://mail.python.org/mailman/listinfo/python-list