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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
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 Wed, 13 Jan 2016 13:53:40 -0200
Lines 22
Message-ID <mailman.109.1452700467.13488.python-list@python.org> (permalink)
References <f2711b57-7b11-4fd5-8bab-a3e8581177b5@googlegroups.com> <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>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de E9o5UIIC8NHn4MB+8i+chArLCGqPAgdvroQTt1qAX1Yg==
Return-Path <mafagafogigante@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.056
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'subject:Python': 0.05; 'subject:getting': 0.07; '*key*.': 0.09; 'assume': 0.11; 'jan': 0.11; 'wed,': 0.15; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'object.': 0.22; 'sorry,': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'message-id:@mail.gmail.com': 0.27; 'way?': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'another': 0.32; "d'aprano": 0.33; 'steven': 0.33; 'tue,': 0.34; 'except': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'too': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; '12,': 0.37; 'received:209': 0.38; 'mean': 0.38; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'skip:n 10': 0.62; 'making': 0.62; 'intent': 0.66; 'course.': 0.67; 'answer.': 0.72; 'saw': 0.77; 'bernardo': 0.84; 'does?': 0.84; 'subject:value': 0.84; 'sorry.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=wuD+nNFAezwrYec8DkiQxdo89eVr7NzqBJ9wfHb7r5M=; b=AAez0vWaZjem8HG0LgfNxBayWhPQRLUI+3trhihCFJpYwnVUMkakhnFjSSv4XZs8Gj Hur8ICRSS28h/dfZiYjOhcbCqn0VnRG2hLJe8c+sUnQW+vNISQPWyevryGidMQVHuZ9g RGBKnj/7aOyS1djTzIDkzHCRhsYl/dhE6/pwPT0ztswnEg5M50+t11ASu3liAJnHaUfe +Zg916F9ldWjxjyigAlZ7cdLmu2OOWuzz7H0M6cV0xgMzHRGVywS6sqkW/LOE9zoNTgT eASqsTKPtLqVhEDgjJFMscBn7EarocDn9sRNaJgG/bCXpzgm4WNaOGHVmFWiGkO0/Axz PIwA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=wuD+nNFAezwrYec8DkiQxdo89eVr7NzqBJ9wfHb7r5M=; b=jlnTA1dhxDlMAN6hKzXhd9g6s0lc9hMvXl8h5JP8PB45ozNaRwp+cjmqlbG4m9wBwo aa+ft1TUPWN22tXmcVvzDrb6uyeL8VLcqexpHRhEh8pJymwDYwzIwe3yKayLvUKM1vvO VstEVeKW1Q7Np9I+qo32tXd8tbUYSAs2Wpgqz2yzdKtp5I/Ac8r4Jg4cfXJsYo5w2wvf TGFJY6n9bCso9gs5AVX4SFIOnJMlJWrVW1XU4Q7vAiXswf85RuahLhXXqsg7m+TNQf74 ZTS9zImi03nQyfqd5+bDH0zF3gFW6ReMSed4w8lTSF468ND03gONy7kUQzRtA/r0fPZ/ GF6A==
X-Gm-Message-State ALoCoQlkPW1PmqYCUfMOUEQxPMoVKd/w599Z7WrZofcFF3ZApjzHlaL+sLGZ2mKWNsiu+tpi0HRaNjethuFzM5vk+o6oV4Vzmw==
X-Received by 10.112.199.41 with SMTP id jh9mr1269193lbc.125.1452700460009; Wed, 13 Jan 2016 07:54:20 -0800 (PST)
In-Reply-To <5695a86c$0$1588$c3e8da3$5496439d@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:101626

Show key headers only | 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