Translating JS equation to PY in code command

Hi all,

I originally ran a PsychoPy script online via Pavlovia during COVID. Now, I am trying to adapt my script to be run locally–that is, I am converting my JS coding to Python.

In my original JS coding, I added some equations to calculate the approximate refresh rate of the participants monitors. However, when translating to Python, two problems emerge:

(1) The output to the first equation is incorrect, and
(2) The second equation yields this error code: TypeError: unsupported operand type(s) for /: ‘int’ and ‘NoneType’

Can anyone help out with this? The coding chunks are pasted below.
Many thanks!!!

average_refresh_duration = (duration_clock.getTime()*1000)/frame_count
average_refresh_duration = thisExp.addData(‘average_refresh_duration’,average_refresh_duration)

approx_frame_rate = 1000/average_refresh_duration
approx_frame_rate = thisExp.addData(‘approx_frame_rate’, approx_frame_rate)


when your equation (1) is not solved, equation (2) will fail as average_refresh_duration is not defined. Why not add some print-commands to see what values your variables have?

print(average_refresh_duration) aso.

You might want to take a look here.

Best wishes Jens