Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info>: > Marko Rauhamaa wrote: >> I prefer the Scheme way: >> #f is a falsey object >> everything else is a truthy object > > The Scheme way has no underlying model of what truthiness represents, just > an arbitrary choice to make a single value have one truthiness, and > everything else the other. It's just as meaningless and just as arbitrary > as the opposite would be: > > #t is True > everything else is falsey > [...] > I'd rather the Pascal way: > > #t is True > #f is False > everything else is an error
An advantage of the Scheme way is the chaining of "and" and "or". For example, this breaks in Python: def dir_contents(path): if os.path.isdir(path): return os.listdir(path) return None def get_choices(): return dir_contents(PRIMARY) or \ dir_contents(SECONDARY) or \ [ BUILTIN_PATH ] Marko -- https://mail.python.org/mailman/listinfo/python-list