Arnaud Delobelle, 28.10.2010 20:38:
using ~-n instead of n-1 if obfuscatory and doesn't even save keystrokes! (Although it could in other situations, e.g 2*(n-1) can be written 2*~-n, saving two brackets.)
Sure, good call. And look, it's only slightly slower than the obvious code: $ python3 -m timeit -s "n=30" "2*~-n" 10000000 loops, best of 3: 0.0979 usec per loop $ python3 -m timeit -s "n=30" "2*(n-1)" 10000000 loops, best of 3: 0.0841 usec per loop Stefan -- http://mail.python.org/mailman/listinfo/python-list