lundi 25 novembre 2019

Prevent Python from checking syntax errors inside an if statement whose condition isn't met

(I totally understand that return only makes sense inside functions.)

My question is: given that list in the following code is not None, is there a way to prevent Python from flagging the presence of return as a syntax error, and interrupting the execution?

list = [1,2,3]
if list is None: 
    return []
list = list + [4]

I'm asking this because I often run chunks of code inside a function to see what it does, step by step.

I don't mind the code execution being interrupted when the condition of the if statement is met, obviously.

But I wonder if there's a way to prevent python from checking syntax errors when they are inside an if statement whose condition is not met.

Aucun commentaire:

Enregistrer un commentaire