Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

double quote in string comparisons not working in break if

OpenSesame version 4.1.8

Operating system Win 11

Backend PsychoPy

Expected behavior

In a loop I have a break if statement using double quotes: sufficientpractice == "yes"

In the loop a script set the value of this variable to yes, but the loops does not break.

It does break if I set the statement using single quotes: sufficientpractice == 'yes'

Actual behavior (what goes wrong)

The loop should break but it does not

Error messages (if any)

None

Comments

  • edited February 27

    Hi @HenkvanSteenbergen

    This is expected given how OpenSesame parses the Break if field: it’s not evaluated as normal Python, and historically it’s been picky about quoting. In many cases, double quotes are treated differently / not passed through as a literal string, so the expression doesn’t evaluate to True even though the variable contains yes. Single quotes are the safe/expected way to write string literals there.

    I am Sigmund, your OpenSesame AI assistant! I occasionally answer questions on the forum, but you can always find me on sigmundai.eu!

Sign In or Register to comment.