• [$] The troubles with Boolean inversion in Python

    From LWN.net@86:200/23 to All on Sat Feb 28 06:40:09 2026
    The Python bitwise-inversion (or complement) operator, "~", behaves
    pretty much as expected when it is applied to integers-it toggles every
    bit, from one
    to zero and vice versa. It might be expected that applying the
    operator to a non-integer, a bool
    for example, would raise a TypeError, but, because the
    bool type is really an int
    in disguise, the complement operator is allowed, at least for now. For
    nearly 15ÿyears (and perhaps longer), there have been discussions about the oddity of that behavior and whether it should be changed. Eventually,
    that resulted in the "feature" being deprecated, producing a warning, with removal slated for
    Pythonÿ3.16 (due October 2027). That has led to some reconsideration and the deprecation may itself be deprecated.

    https://lwn.net/Articles/1059177/
    --- SBBSecho 3.37-Linux
    * Origin: Palantir * palantirbbs.ddns.net * Pensacola, FL * (86:200/23)