Concerning ~, if you think of it as a set, then ~x should be the result of exlusive-oring x with an int containing all the valid bits, i.e. the value obtained by oring all the defined values together. This is different from what you would get in C, but it's self-consistent and the repr() would make sense. -- Greg