[Python-ideas] Should bool continue to inherit from int?

Steven D'Aprano steve at pearwood.info
Fri Jan 23 08:41:44 CET 2015


On Wed, Jan 21, 2015 at 06:12:13PM +0000, MRAB wrote:

> Pascal has 'ord' for getting the ordinal number from an enumerated
> type, so perhaps that could be used:
> 
> ord(False) == 0
> ord(True) == 1
> 
> Currently it's just the inverse of 'chr'.

In Python, that is spelled 

int(False)  # returns 0
int(True)  # returns 1


-- 
Steve


More information about the Python-ideas mailing list