Re:True hacker resume: CV as Python unit test
by masklinn on Thursday July 15, 2010 @06:01PM
(#1519394)
> Not in this case, but Yoda conditions can be useful.
Not in Python. Assignments as anything but stand-alone (potentially chained) statements are syntax errors.
The parser will not let you write
if something = 2:
in the first place.
Re:True hacker resume: CV as Python unit test
by acangiano on Thursday July 15, 2010 @06:13PM
(#1519435)
That's why I said "not in this case". There are languages affected by this though (typically C-based ones). Ideally, their compiler will give you a warning about it, but that's not always the case.
Say that you mean to do:
If you forget an equal sign, the resulting code can lead to subtile bugs: If you are using a Yoda condition and forget an equal sign, you'll get an error right away (so that you can correct it): There are other use cases, particularly related to nil values, but this should show you the gist of it.