hg wrote: > Hi, > > In C/C++ I got used to write an expression like so: > > #define TEST 0 > > if (TEST == value) > { > > } > > in order to avoid the usual bug: > if (value = TEST) > { > > } > > In a relatively similar domain, I spent a few hours find this bug: > > value == self.Get_Value() > if value == WHATEVER: > do this > > instead of > value = self.Get_Value() > if value == WHATEVER: > do this > > Is there a way to avoid such a bug with some type of construct ?
No. In a language inherent with sideeffects, there is nothing that should force you to not write that. However, it might be that either pychecker or pylint will give you a warning for such statements. Diez -- http://mail.python.org/mailman/listinfo/python-list