== Thinking about the Python equivalents of C's _!!_ double negation C's _!!_ double negation idiom is a way of compressing all non-zero values of an expression down into a 1. There's a number of things that you can use to get the same effect in Python: * if you know that your result is always zero or positive, you can use _cmp()_. I'm ambivalent about whether this is obscure usage; you're at least making it clear what you're doing, although probably not why. (If your result can be negative, you can use _abs(cmp(...))_.) * the minimalist version is just _bool(...)_, because (currently) _True_ and _False_ can be directly used in arithmetic expressions. * writing _int(bool(...))_ has the same effect but makes it clear to readers (and programs like pylint and pychecker) that you're doing this deliberately. I'm not sure which one I like better. Consider an expression like: > nbytes = nbits // 8 + int(bool(nbits % 8)) My C heritage says that this version is the clearest (and indeed it's the first one I thought of). I'd have to pause to think about the _cmp()_ version, partly because I've yet to memorize which way _cmp()_'s arguments run so I always have to think about what its result will be. I suspect that none of these would be considered good Python style, and that the proper Pythonic way to do this is to just use an _if_, or to write the whole thing as _math.ceil(nbits / 8.0)_ and trust that floating point precision is not going to bite you. (For some reason I have a small addiction to little overly clever Python idioms like this.)