#1 by nathalie
Hi everyone, does field_maybe_none work for participant variables, too? I want to check whether they are empty (specifically: player.field_maybe_none('participant.field') is not None) I tried player.field_maybe_none('participant.field') and player.participant.field_maybe_none('field') but both return an error. Thank you for helping! Nathalie
#2 by gr0ssmann
I usually do "fieldname" in player.participant.vars So, for example: if "bonus" not in player.participant.vars: player.participant.vars["bonus"] = 0 However, typically I'd say this is an "anti-pattern"; I would always ensure at the beginning that fields have some default or initial value set.
#3 by Fanist
I agree with @gr0ssmann that it is better to set some initial values. For example, you can set "gender" to be -99 if no other rewriting is triggered, and let gender==-99 be the signal that the field is none.
#4 by nathalie
Thank you! That worked :-)