jeudi 21 avril 2016

strange if elif control flow

I have the following if elif control flow,

if string1 == "val1":
   # some code
elif string2 == "val2" and function1(func1_value1, func1_value2):
   # some code
elif function2(func2_value):
   # some code

Now, the interesting thing is when the control flow checks the condition of the first elif and executes the block of code, then it also checks the seond elif. This is unexpected, as I thought once a elif executes, no other conditions will be checked again.

ps. was using PyCharm debugger to debug the code, and found out such thing

Aucun commentaire:

Enregistrer un commentaire