Creating multible Stims with function

Hello everyone,
I m trying to create a mask for my experiment using the PsychoPy Coder but I have some issues with my code.
The mask_screen consisted of 200 crosses normally distributed around the center of the screen, but because it will appear many times throughout the experiment I tried to create it with a function and call it when necessary.
the code I write is the following:

def mask():
import numpy as np
import psychopy.visual
pos_X = np.random.normal(0, 3.1, 200)
pos_Y = np.random.normal(0, 3.1, 200)

for i in range (200):
    str("vertical_line_") + str("i") = visual.Line(win = win, start= (pos_X[i]-3, pos_Y[i]), 
        end= (pos_X[i]+3, pos_Y[i]), units = 'deg', lineColor = [-1, -1, -1])
    vertical_line_("i").draw()
    str("horizontal_line_") + str("i") = visual.Line(win = win, start= (pos_X[i], pos_Y[i]-3), 
        end= (pos_X[i], pos_Y[i]+3), units = 'deg', lineColor = [-1, -1, -1])
    horizontal_line_("i").draw() 

The error:
File “C:\Users\user\Desktop\peiramata_Psychopy\untitled.py”, line 8
** str(“vertical_line_”) + str(“i”) = visual.Line(win = win, start= (pos_X[i]-3, pos_Y[i]), **
** ^**
SyntaxError: can’t assign to operator
##### Experiment ended. #####

My questions are:
A) Is it possible to create this type of Stims with a function?
B) Is it just a typo? did I write something wrong?

Sorry for the long post!

I think the main issue is that you are attempting to assign an object to a string. Take a look at the simpleGrid demo attached. It breaks down the problem into stages

  1. Function to create objects and store them in list - the list is returned from the function
  2. Separate function for drawing objects stored in a list.

If you need your objects to have a unique name, then you can add the unique identifier to the objects “name” parameter when you create the object.

simpleGrid.psyexp (14.5 KB)

Aw I see!
although I don’t know exactly how to implement this, I get the idea! Thanks, this is pretty helpful!