Boolean idioms (was Re: re Challenge: More Compact?)

Terry Reedy tjreedy at home.com
Mon Jul 16 23:31:38 CEST 2001


> I know that it's a frequent Python idiom to use 0/1, but where is it
> specifically un-Pythonic to use None/1?

Since conditionals return 0/1, that is the expected range for predicates,
and it often takes more work to return None.

However, I personally prefer None to an artificial -1 answer based on
pre-Python solutions in languages that did not have None (or the
equivalent) available.

Terry J. Reedy






More information about the Python-list mailing list