Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101626

Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict

From Bernardo Sulzbach <mafagafogigante@gmail.com>
Newsgroups comp.lang.python
Subject Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict
Date 2016-01-13 13:53 -0200
Message-ID <mailman.109.1452700467.13488.python-list@python.org> (permalink)
References (1 earlier) <n73dc3$jcn$1@ger.gmane.org> <CAERt=-ygqTcyHRd74MAfNueRagwGZd42sE+YaXMGbpJUGk=vHA@mail.gmail.com> <n73ie7$a81$1@ger.gmane.org> <mailman.83.1452625998.13488.python-list@python.org> <5695a86c$0$1588$c3e8da3$5496439d@news.astraweb.com>

Show all headers | View raw


On Tue, Jan 12, 2016 at 11:29 PM, Steven D'Aprano <steve@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

subscripting Python 3 dicts/getting the only value in a Python 3 dict Nick Mellor <thebalancepro@gmail.com> - 2016-01-12 08:50 -0800
  RE: subscripting Python 3 dicts/getting the only value in a Python 3 dict Emanuel Barry <vgr255@live.ca> - 2016-01-12 12:00 -0500
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Chris Angelico <rosuav@gmail.com> - 2016-01-13 04:06 +1100
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Terry Reedy <tjreedy@udel.edu> - 2016-01-12 12:12 -0500
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-12 15:18 -0200
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Peter Otten <__peter__@web.de> - 2016-01-12 18:32 +0100
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-12 10:39 -0700
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-12 19:47 +0200
    Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Marko Rauhamaa <marko@pacujo.net> - 2016-01-12 21:42 +0200
      Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-12 22:18 +0200
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Peter Otten <__peter__@web.de> - 2016-01-12 19:09 +0100
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-12 16:48 -0200
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Peter Otten <__peter__@web.de> - 2016-01-12 19:59 +0100
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-12 17:12 -0200
    Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Steven D'Aprano <steve@pearwood.info> - 2016-01-13 12:29 +1100
      Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-13 13:53 -0200
  Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Steven D'Aprano <steve@pearwood.info> - 2016-01-13 12:23 +1100
    Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict Grant Edwards <invalid@invalid.invalid> - 2016-01-13 15:58 +0000

csiph-web