jeudi 8 juillet 2021

Confusing (double?) if statement [duplicate]

i have a question about this if statement. It is a one liner and I don't seem to understand what it does.

clin = load_data_from_path(dd, "tcga", "patient", "new_tumor_events", "new_tumor_event_after_initial_treatment", "text")
if clin: data[case]['recurrence'] = 1 if clin == "YES" else 0

Does this mean something like, if clin exists, change recurrence to 1, but only if clin == YES, because otherwise it should be 0?

If so, why do it like the first expression and not like the following:

if clin == "YES":
   data[case]['recurrence'] = 1
else :
   data[case]['recurrence'] = 0

I think the latter probably isn't the same so can someone please explain?

Aucun commentaire:

Enregistrer un commentaire