On Tue, Jul 28, 2020 at 5:24 AM Steven Barker <blckkn...@gmail.com> 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 p.id == '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 p.id == '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.) ChrisA _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/62ZAKSHT6VHT66CHFBPJHHAUQSW2S3DK/ Code of Conduct: http://python.org/psf/codeofconduct/