Re:True hacker resume: CV as Python unit test
by masklinn on Thursday July 15, 2010 @06:00PM
(#1519386)
> 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.Dumb is a strong word, young padawan.
The difference between theory and practice is smaller in theory than in practice.
Re:True hacker resume: CV as Python unit test
by masklinn on Friday July 16, 2010 @01:49AM
(#1520404)
> Dumb is a strong word, young padawan.
I carefully weighted my words, and I rest my case.
> 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
Re:True hacker resume: CV as Python unit test
by chromatic on Thursday July 15, 2010 @10:40PM
(#1520029)
Perl does indeed warn about the use of = instead of == in a conditional.
You're right; I didn't know about the -w setting. I guess that just leaves PHP.
Re:True hacker resume: CV as Python unit test
by subwindow on Friday July 16, 2010 @11:13AM
(#1521368)
That'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.
Putting the constant left in a conditional means you will never miss an accidental = instead of ==.