|
|
|
|
|
by owl57
1460 days ago
|
|
Python implicit string iteration is an annoying trap. COMPLETE_STATES = 'done', 'cancelled'
if state in COMPLETE_STATES:
…
Then you decide to handle cancelled tasks separately. COMPLETE_STATES = 'done'
Boom!Can't remember a less contrived example right away, but I have broken real code by inadvertently calling string iteration and spent some time scratching my head. Granted, don't think I've seen something like this in a PR, only in local development. P.S. I think last time I stumbled on this, it actually involved Django ORM and changing filter(state__in=COMPLETE_STATES) to filter(state__in=DONE). |
|