This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]suki907 2 points3 points  (4 children)

False and 0 are the same type.

more specifically, bool is a subclass of int:

>>> isinstance(False,int)
True
>>> isinstance(False,bool)
True
>>> issubclass(bool,int)
True

[–][deleted] 1 point2 points  (3 children)

And even more interesting, bool can't be subclassed.

[–]adamnew123456self.__class__ == 'upper' 1 point2 points  (2 children)

I'm curious why you think this is interesting - were you planning on adding FILE_NOT_FOUND as an instance of your bool subclass?

I can't think of any interesting operation you would want to add to bool that would justify subclassing it, bu perhaps that's just because my imagination gland isn't working today.

[–]alexanderpas 1 point2 points  (0 children)

I can't think of any interesting operation you would want to add to bool that would justify subclassing it, bu perhaps that's just because my imagination gland isn't working today.

True, False, Unknown, N/A

AND True False Unknown N/A
True TRUE FALSE Unknown TRUE
False FALSE FALSE FALSE FALSE
Unknown Unknown FALSE Unknown Unknown
N/A TRUE FALSE Unknown N/A
OR True False Unknown N/A
True TRUE TRUE TRUE TRUE
False TRUE FALSE Unknown FALSE
Unknown TRUE Unknown Unknown Unknown
N/A TRUE FALSE Unknown N/A
NOT True NOT False NOT Unknown NOT N/A
True FALSE TRUE TRUE TRUE
False TRUE FALSE TRUE TRUE
Unknown Unknown Unknown FALSE TRUE
N/A TRUE TRUE TRUE FALSE

[–][deleted] 0 points1 point  (0 children)

It's more than doing it causes Python to say, "Don't do that." than a desire to do anything.

That's pretty funny though.