5 ms·
May be irritating for some but good practice regardless. Putting the constant left in a conditional means you will never miss an accidental = instead of ==.
by moe 16y ago
May be irritating for some but good practice regardless.
Putting the constant left in a conditional means you will never miss an accidental = instead of ==.
- masklinn 16y ago> Putting the constant left in a conditional means you will never miss an accidental = instead of ==. That's only useful for dumb languages >>> a = 5 >>> if a = 3: print 'ok'; else: print 'nok' File "<stdin>", line 1 if a = 3: print 'ok'; else: print 'nok' ^ SyntaxError: invalid syntax Python simply does not allow assignments in conditional contexts.
- moe 16y agoDumb is a strong word, young padawan. The difference between theory and practice is smaller in theory than in practice.
- masklinn 16y ago> Dumb is a strong word, young padawan. I carefully weighted my words, and I rest my case.
- 146 16y ago> That's only useful for dumb languages The compilers/interpreters I know that don't do this are PHP and Perl (C/C++ will do it if you use -Wall, which you should be using anyway). So yeah, you're pretty much right. /snark
- subwindow 16y agoThat's like wearing a helmet while walking down the street because you might accidentally fall and hit your head. Don't be an idiot in the first place and you won't have to do idiotic things to prevent damage from your idiocy.
- moe 16y agoGood judgement is the result of experience. Experience is the result of bad judgement. <-- You are here