Oct-31-2019, 07:21 AM
buran explanation backed-up with Python docs (already referenced earlier):
This behaviour enables writing 'clever' code like:
Quote:Operations and built-in functions that have a Boolean result always return 0 or False for false and 1 or True for true, unless otherwise stated. (Important exception: the Boolean operations or and and always return one of their operands.)
This behaviour enables writing 'clever' code like:
>>> lst = [1, 2, 3] >>> for i in lst: ... print(i % 2 and 'odd' or 'even') ... odd even odd
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.