On Tue, 2011-06-07 at 11:03 +0200, M.-A. Lemburg wrote:
Georg Brandl wrote:
On 06/07/11 05:20, brett.cannon wrote:
http://hg.python.org/cpython/rev/fc282e375703 changeset: 70695:fc282e375703 user: Brett Cannon <brett@python.org> date: Mon Jun 06 20:20:36 2011 -0700 summary: Remove some extraneous parentheses and swap the comparison order to prevent accidental assignment.
Silences a warning from LLVM/clang 2.9.
Swapping the comparison order here seems a bit inconsistent to me. There are lots of others around (e.g. "len == 0" in the patch context below). Why is this one so special?
I think that another developer even got told off once for these kinds of comparisons.
I hope the Clang warning is only about the parentheses.
I agree with Georg: "if ('u' == typecode)" is not well readable, since you usually put the variable part on the left and the constant part on the right of an equal comparison.
[FWIW, I'm one of the reprobates that likes to put the constant on the LHS when I'm coding in C, but I see I'm in the minority here] I know that this style is unpopular, but if it helps, try mentally pronouncing "==" in C as "is the value of". In this example, when I read that line, my mind is thinking: "if 'u' is the value of typecode" After ~12 years of doing this, it comes naturally. I appreciate that this may come across as weird though :) [snip] Hope this is helpful Dave