Thanks for the suggestion! I agree that using a list is clearer that having a trailing comma, I like it!

I still think that having a one() function would be useful, since:
1. I think it spells the intention more clearly. Also the exception would be easier to understand, since errors in tuple unpacking usually mean something else.
2. The one() function allows you to use the result inside an expression without assigning it to a variable.


On Mon, Jul 27, 2020 at 10:30 PM Chris Angelico <> wrote:
On Tue, Jul 28, 2020 at 5:24 AM Steven Barker <> wrote:
> A single-name unpacking assignment can do exactly what you want, albeit with slightly less helpful exception messages:
>     jack, = (p for p in people if == '1234') # note comma after the name jack

Agreed. As a minor readability refinement, I would prefer to spell
this with square brackets:

[jack] = (p for p in people if == '1234')

The effect is identical, but for the one-item unpack, I prefer not to
have the vital-but-subtle trailing comma.

(You can use square brackets on larger assignment lists too, but they
don't add anything.)

Python-Dev mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct: