Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • BTW, there is no good reason to "reverse" comparisons to a constant like that in Python. Accidentally writing = would be a syntax error, and there are no "null pointers" to worry about - None == 'foo' simply (and correctly) evaluates to False. Commented Mar 1, 2022 at 1:46
  • Anyway, seriously, you want to use relative imports for this. Commented Mar 1, 2022 at 1:47
  • Hi @KarlKnechtel, the way I see it is actually I would rather get a syntax error than a logical error. care to explain more? Commented Mar 4, 2022 at 8:11
  • In Python, you will get a syntax error rather than a logical error, whether or not you reverse the condition; so there is no reason to reverse the condition. In Python's grammar, = is part of an assignment statement, which is not a kind of expression (unlike C and C++ where assignments are a kind of expression). Commented Mar 5, 2022 at 23:29