On Fri, 05 Mar 2010 18:14:16 +0100, mk wrote: >>>> isinstance(False, int) > True > >>> > >>> isinstance(True, int) > True > > Huh?
Yes. Do you have an actual question? > >>> issubclass(bool, int) > True > > Huh?! Exactly. Bools are a late-comer to Python. For historical and implementation reasons, they are a subclass of int, because it was normal for people to use 0 and 1 as boolean flags, and so making False == 0 and True == 1 was the least likely to break code. E.g. back in the day, you would have something like: {2:None}.has_key(2) -> 1 So folks would do: print "The key is", ["missing", "present"][d.has_key(key)] Which still works even now that has_key returns True or False rather than 1 or 0. -- Steven -- http://mail.python.org/mailman/listinfo/python-list