I am a newbie and I would like to ask what is psychopy.constants? Why can't I find psychopy.constants in the api?

I am a newbie and I would like to ask what is psychopy.constants? Why can’t I find psychopy.constants in the api?

psychopy.constants is a script of constants. :smiley:
The script mainly contains the following code:

NOT_STARTED = 0
PLAYING = 1
STARTED = PLAYING
PAUSED = 2
STOPPED = -1
FINISHED = STOPPED
SKIP = -2
STOPPING = -3

# for button box:
PRESSED = 1
RELEASED = -1

# while t < FOREVER ... -- in scripts generated by Builder
FOREVER = 1000000000  # seconds

These constants are useful, because then you don’t have to remember, what values you used for the variable indicating whether the presentation of a stimulus is not started (0), playing (1), paused (2), or stopped (-1). Using these variable names instead of the integers they represent makes the code more readable.

For lab-based experiments: I don’t think there is documentation of these constants anywhere, but you can look them up the source code here. If you want to know what they do in the background of your builder components, you can always compile your script and read it in the coder view.

For online experiments: I’m not an expert for online experiments, but I would be surprised if they played a different role in JS. If you understand their usage in Psychopy and Python, you can probably just transfer this knowledge to PsychoJS.

2 Likes

Thank you for your answer.

1 Like