top_row and (b.mask + (1 shl (7 * row))) == 0 gives a error while (top_row and (b.mask + (1 shl (7 * row)))) == 0 gives the result I want. notice that b.mask is a int64 and so is top_row. I think I know why this occurs. since with the brackets and becomes binary and, then without the brackets it becomes a logical and. Is this intended behavior?