These need gardening but I'll just put them here to keep track.
def get_any(dict, *keys, default=None):
"""Cascading get, for those times you do `dict.get(key1, dict.get(key2, ...))"""
for key in keys:
if key in dict:
return dict[key]
return default
But I had another take on get_any() here, so need to resolve that.
#266
Another one is a multi-partition, where predicates cascade:
future, current, past = partition(items, lambda item: item.start > now, lambda item: item.end > now)
(this could be an extension of iterutils.partition to accept any number of predicates instead of just one)
These need gardening but I'll just put them here to keep track.
But I had another take on
get_any()here, so need to resolve that.#266
Another one is a multi-partition, where predicates cascade:
(this could be an extension of iterutils.partition to accept any number of predicates instead of just one)