4 ms·
Yep, that's a pattern I've applied before. It's not the worst, but I don't think it has the clarity that this would have: key, value ?= item.split("=", 1)
by woodruffw 5y ago
Yep, that's a pattern I've applied before. It's not the worst, but I don't think it has the clarity that this would have:
key, value ?= item.split("=", 1)
Modulo bike shedding over the actual syntax, of course.
(Edit: the semantics of this could be even more generic, like Ruby's `[...] rescue value` syntax for turning any raised exception into a default value instead.)
- xtreak29 5y agoThere was a similar PEP https://peps.python.org/pep-0505/ https://peps.python.org/pep-0505/