coercing to Unicode: need string or buffer, int found
Hi,
I'm designing an experiment in open sesame and I've encountered the following problem:
I'm defining a variable called total_correct_t inside a loop without any values.
I update it in this inline script:
if var.correct == 1:
var.total_correct_t += 1
Whenever that correct == 1 Im getting the error below. Is there any different way for defining variables in open sesame?
I feel like I'm missing something. It doesn't feel right to define the variables I want to document in the independent_variables table.
Thanks,
The error I got:
Error while executing inline script
item-stack: experiment[run].training_loop[run].block_sequence_t[run].block_loop_t[run].trial_sequence_t[run].update_total_correct_t[run]
exception type: TypeError
exception message: coercing to Unicode: need string or buffer, int found
item: update_total_correct_t
time: Wed Aug 22 11:01:49 2018
phase: run
Traceback:
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/inline_script.py", line 96, in run
self.experiment.python_workspace._exec(self.crun)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/base_python_workspace.py", line 124, in _exec
exec(bytecode, self._globals)
Inline script, line 2, in
TypeError: coercing to Unicode: need string or buffer, int found
Comments
Hi Amir,
i am not sure if that helps, but here some suggestions.
Your operation += is not (yet) supported.
Try to run just this code:
total_correct_t += 1
Suggestion:
Implement the variable beforehand (maybe another inline_script)
var.total_correct_t == 0
Then use at your position this code: (be careful with indentation)
Good luck
Stephan