> > 2nd question: > [snip] > > if x>10 and y>10 and z>10 and summ(tritup(x,y,z)): print "OK" > > Others have already suggested you use the built-in sum() function. > > I'll suggest you don't need it at all, because it is redundant. > > If the sum is zero, either all three values are zero or at least one of > the values is negative. In either case the first test will fail. > > There are no circumstances where each of x, y and z are greater than 10 > but the sum is zero; nor are there any circumstances where the sum is > zero but x, y and z are still all greater than 10.
Unless, of course, the function tritup returns negative values. My guess is that the "> 10" tests are protecting the tritup function, and possibly should be moved there. Without the details of the function, I can't tell, but it may be incorrect to remove those tests. Which brings us to the other bit of advice - unit tests protect you from yourself and from those who optimize too quickly. -- http://mail.python.org/mailman/listinfo/python-list