Non-ASCII Characters in Comments

266 views
Skip to first unread message

Alex Chase

unread,
Jul 4, 2013, 8:33:36 AM7/4/13
to psychop...@googlegroups.com
I'm putting together a kind of proof-of-concept experiment and wanted to use a mixture of ASCII and Unicode characters as stimuli. In order to keep clear in my code what a "text = u'\u25D3'" actually was, I put a comment after the line with the Unicode character itself. This caused a "SyntaxError: Non-ASCII character on line 36, but no encoding declared" output. Doesn't matter if it's a #comment or a """comment""".

Is there a reason for PsychoPy to assess the syntax/encoding of comments?

Jeremy Gray

unread,
Jul 4, 2013, 8:39:01 AM7/4/13
to psychop...@googlegroups.com
Hi Alex,

This is almost certainly a python issue, not a psychopy issue.

Try starting your experiment with these two lines:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

--Jeremy


On Thu, Jul 4, 2013 at 8:33 AM, Alex Chase <aec...@gmail.com> wrote:
I'm putting together a kind of proof-of-concept experiment and wanted to use a mixture of ASCII and Unicode characters as stimuli. In order to keep clear in my code what a "text = u'\u25D3'" actually was, I put a comment after the line with the Unicode character itself. This caused a "SyntaxError: Non-ASCII character on line 36, but no encoding declared" output. Doesn't matter if it's a #comment or a """comment""".

Is there a reason for PsychoPy to assess the syntax/encoding of comments?

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/00e90695-f6eb-479d-b111-1799da7ffaf7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jonas Lindeløv

unread,
Jul 5, 2013, 12:08:08 PM7/5/13
to psychop...@googlegroups.com
... and maintain that "u" as prefix to strings wherever you can. PsychoPy often throws an error if you don't. The second of these is good:

stim.setText('danes have these weird letters: æøå')
stim.setText(u'danes have these weird letters: æøå')

Best,
Jonas
Reply all
Reply to author
Forward
0 new messages