|
|
Subscribe / Log in / New account

Python first()

Python first()

Posted Jan 5, 2020 1:26 UTC (Sun) by excors (subscriber, #95769)
In reply to: Python first() by intgr
Parent article: Python first()

Isn't that simply "(item,) = iterable" (or even "item, = iterable"), which unpacks into a tuple of size 1 and throws ValueError if there are too few/many values?


to post comments

Python first()

Posted Jan 9, 2020 12:49 UTC (Thu) by intgr (subscriber, #39733) [Link]

That's a very nice short and idiomatic way of implementing that.
Thanks, I hadn't thought of it! :)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds