mardi 26 mai 2020

Python: logical (IF is not None) not complying

I have a normal if statement in Python. The condition of the if-statement is False as you can see in the debugger (screenshot, hovering over the condition). inmodel is None, so the condition inmodel is not None should be False and the debugger agrees. Yet while going to the next line, the python interpreter does enter the first line after the if statement which it shouldn't (as you can see by the blue line). The screenshot below illustrates it best.

Screenshot debugger

EDIT: it seems that many do not understand the question. The expression is FALSE AS IT SHOULD BE. The problem is that while the expression is False, the interpreter does go to line 123 while the if statement on line 122 says False.

EDIT2: replacing line 122 by if inmodel: results in the same. Removing __pycache__ folders and restarting IDE, computer also does not help. I will assume that there is no coding error, just a python bug or something like that.

Aucun commentaire:

Enregistrer un commentaire