replace 'cond and one or tother' idiom with 'one if cond or tother' #2377

Open
opened 2015-02-06 22:55:01 +00:00 by daira · 0 comments
daira commented 2015-02-06 22:55:01 +00:00
Owner

In Python pre-2.5, the nearest equivalent to C's cond ? one : tother was the idiom cond and one or tother.
In Python 2.5+, a more precise equivalent is one if cond else tother.

The former is error-prone: it evaluates to tother when one is falsy, which is the wrong thing. Since Tahoe-LAFS requires at least Python 2.6, we can always use the latter.

("t'other" is Northern English dialect for "the other", if you were wondering about that.)

In Python pre-2.5, the nearest equivalent to C's `cond ? one : tother` was the idiom `cond and one or tother`. In Python 2.5+, a more precise equivalent is `one if cond else tother`. The former is error-prone: it evaluates to `tother` when `one` is falsy, which is the wrong thing. Since Tahoe-LAFS requires at least Python 2.6, we can always use the latter. ("t'other" is Northern English dialect for "the other", if you were wondering about that.)
tahoe-lafs added the
code
normal
defect
1.10.0
labels 2015-02-06 22:55:01 +00:00
tahoe-lafs added this to the undecided milestone 2015-02-06 22:55:01 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac-2024-07-25#2377
No description provided.