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?
Posted Jan 9, 2020 12:49 UTC (Thu)
by intgr (subscriber, #39733)
[Link]
Python first()
That's a very nice short and idiomatic way of implementing that.
Thanks, I hadn't thought of it! :)