Re:Python idiom for taking the single item from a list
by StavrosK on Monday September 27, 2010 @02:37PM
(#1732806)
Not really. The first two are consistent, but the last one is "get the only item and assert that there is only one item to get. If you don't care about the assertion, use [0], as always. I like the latter, because there's added info for the reader ("this should return a one-item iterable").
It's not really inconsistent, because you aren't performing the same operation in the two cases.
It's not really inconsistent, because you aren't performing the same operation in the two cases.