anon added the comment: I think the case where i is negative can be handled by bits_at(i, pos, width) = bits_at(~i, pos, width) ^ ((1 << width) - 1) ---------- _______________________________________ Python tracker <report at bugs.python.org> <http://bugs.python.org/issue19915> _______________________________________