PEP 285

I think it was a good idea to add a boolean type to Python, but I don't agree entirely with PEP 285. Specifically:
4) Should we strive to eliminate non-Boolean operations on bools in the future, through suitable warnings, so that for example True+1 would eventually (in Python 3000) be illegal?
8) Should we strive to require that Boolean operations (like "if", "and", "not") have a bool as an argument in the future, so that for example "if []:" would become illegal and would have to be writen as "if bool([]):" ???
I say yes to both, but the BDFL said no. I say yes because it makes code more readable, reduces the chance of error, and doesn't seem to have any great disadvantages. In the example, instead of if []: I would write if len([]) > 0:. This approach would also solve the last of the 'resolved issues', because writing:

if x == True: ...

would mean the same as:

if x: ...

No comments:

Post a Comment