psychopy.org | Reference | Downloads | Github

?lineColor syntax error

Hello,

I am a complete newby to programming (as you will see). My code is exactly the same as in the book I am reading:

from constants import DISPSIZE, FGC

from psychopy.visual import Window, Circle
from psychopy.core import wait

disp = Window(size = DISPSIZE, units=“pix”, fullscr=True)
fixmark = Circle (disp, radius = 6, edges = 64,
???lineColor=FGC, fillColor = FGC)

fixmark.draw()
disp.flip()
wait(2)
disp.close()

However, when trying to run the experiment, I get this note:

File “experiment.py”, line 11
???lineColor=FGC, fillColor = FGC)
^
SyntaxError: invalid syntax

Where’s the problem?

The problem seems to be the question marks!

There shouldn’t be question marks in your code, they’re not allowed variable names. You can use upper and lowercase letters, underscores, numbers (in the middle), and a few other characters:

https://docs.python.org/3/reference/lexical_analysis.html#grammar-token-identifier

Try and change the code like so:

from constants import DISPSIZE, FGC

from psychopy.visual import Window, Circle
from psychopy.core import wait

disp = Window(size = DISPSIZE, units=“pix”, fullscr=True)
fixmark = Circle (disp, radius = 6, edges = 64, lineColor=FGC, fillColor = FGC)

fixmark.draw()
disp.flip()
wait(2)
disp.close()

1 Like

Out of interest, what is the book?

Python for Experimental Psychologists by Edwin S. Dalmaijer.

Ah, in my copy of that (but maybe you have the eBook) he uses a symbol that looks like a slightly-strange, square underscore. I think that’s just meant to indicate a space and shouldn’t be copied into the text of your script!

I am using the eBook. I have now noticed that very often when line breaks the next line begins with question marks (which I guess should be ignored).