My favorite function here is more_itertools.one. Especially in something like a unit test, where ValueErrors from unexpected conditions are desirable, we can use it to turn code like results = list(get_some_stuff(...)) assert len(results) = 1 result = results[0] into result = one(get_some_stuff(...)) I guess you could also use tuple-unpacking: result, = get_some_stuff(...) But the syntax is awkward to unpack a single…
result, _* = iterable()