僅驗證 iterable 中的一個元素

使用解壓縮來提取第一個元素並確保它是唯一的元素:

a, = iterable

def foo():
    yield 1

a, = foo()  # a = 1

nums = [1, 2, 3]
a, = nums  # ValueError: too many values to unpack