The curious behavior of integer objects

Jim B. Wilson wilson at
Mon Jan 15 23:28:41 CET 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

More information about the Python-list mailing list