subscripting Python 3 dicts/getting the only value in a Python 3 dict
Bernardo Sulzbach
mafagafogigante at gmail.com
Wed Jan 13 10:53:40 EST 2016
On Tue, Jan 12, 2016 at 11:29 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Wed, 13 Jan 2016 06:12 am, Bernardo Sulzbach wrote:
>
>> I saw it in another answer. next(iter(d)) is still the winner.
>
> Except that doesn't return the *value*, it returns the *key*.
>
There is a typo, sorry. I assume that what is passed to iter is a
dict_values object.
>> This resembles a list just too much, making the coder's intent harder
>> to understand. This is **very** subjective, of course.
>
> I'm sorry, I don't understand what you mean by "resembles a list"? What
> does? In what way?
>
[a] = d.values() resembles a list too much to my eyes.
--
Bernardo Sulzbach
More information about the Python-list
mailing list