The curious behavior of integer objects

Jim B. Wilson wilson at afn.org
Mon Jan 15 17:28:41 EST 2007


Am I nuts? Or only profoundly confused? I expected the this little script
to print "0":

class foo(int): 
  def __init__(self, value):
    self = value & 0xF

print foo(0x10)

Instead, it prints "16" (at least on python 2.4.4 (Linux) and 2.5 (Wine).

Jim Wilson
GNV, FL



More information about the Python-list mailing list