Return the first non-empty value for any candidate key.
(mapping: dict, *keys, default=None)
| 105 | |
| 106 | |
| 107 | def first_present(mapping: dict, *keys, default=None): |
| 108 | """Return the first non-empty value for any candidate key.""" |
| 109 | for key in keys: |
| 110 | if key in mapping and mapping[key] not in (None, ""): |
| 111 | return mapping[key] |
| 112 | return default |
| 113 | |
| 114 | |
| 115 | def first_list(*values) -> list: |
no outgoing calls
no test coverage detected