John Ladasky <john_lada...@sbcglobal.net> writes: > I have gotten used to switching back and forth between Boolean algebra > and numerical values. Python generally makes this quite easy.
Generally ugly though, at least to my tastes. "Explicit is better than implicit" as the saying goes. > If the length of the list L is odd, I want to process it once. If > len(L) is even, I want to process it twice.... > for x in range(1 + not(len(L) % 2)): If you really have to do something like that, I'd say for x in range(1 + (len(L) & 1)): or for x in range(2 - len(L) % 2): are simpler and avoid those bogus bool conversions. I'd prefer to just say the intention: for x in range(1 if len(L)%2==1 else 2): > This provoked a SyntaxError. "not" is a syntactic keyword and "1 + not" is syntactically invalid. You could write "1 + (not ...)" as you discovered, but really, it's hackish. -- http://mail.python.org/mailman/listinfo/python-list