When you're unsure about how Python treats an expression, then the ast¹ module is your friend:
>>> ast.dump(ast.parse('n != x &~ n'), False)
Module([Expr(Compare(Name('n', Load()), [NotEq()], [BinOp(Name('x', Load()), BitAnd(), UnaryOp(Invert(), Name('n', Load())))]))])
It can make it easier to reason through the curiosities, such as the precedence in the given example.Note: Suggesting `ast` as a solution surely proves continuational's point ;)