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


Groups > comp.lang.python > #101568

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 Tue, 12 Jan 2016 16:48:17 -0200
Lines 15
Message-ID <mailman.81.1452624540.13488.python-list@python.org> (permalink)
References <f2711b57-7b11-4fd5-8bab-a3e8581177b5@googlegroups.com> <n73dc3$jcn$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 1G0ljo0BYAC7DwhGvcO2LQP/xWQrLU54DAoA8TN410qQ==
Return-Path <mafagafogigante@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.028
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.05; 'subject:getting': 0.07; 'trailing': 0.07; 'jan': 0.11; '2016': 0.16; 'comma,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; 'looks': 0.29; 'there.': 0.30; 'subject:/': 0.30; 'tue,': 0.34; 'received:google.com': 0.35; 'item': 0.35; 'but': 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; 'wrong': 0.38; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'personally': 0.61; 'bernardo': 0.84; 'otten': 0.84; 'subject:value': 0.84
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=wtsbF7Ozh4Jjh8v4ncbDQx1wSSIyTQCr5vYMGTjmdio=; b=OCP7dq4wKlks1AEOF89FQBU6lq0oUAiNu+nrP39pLDaajwv2Oejw/95DIDnx3x1tJd EFsjxVxhYUnoLvHm01Cb11DR4nEg5Vr6b4NgI970IQN+kfGaQyIU2WO3zrqvpOmF2t8G nTZjDeZ2XJAtDbfoFL+nygjfFhKK6/UjhspAYHPPyu7R23upiE2+qMpQSetl5yjTAL+6 v2/iQxvWLmX8GmXS3GP9mzr+qPlDdRA3421s5YZoPoewG4Zol5OXVnsCjCNfnD6hII0J OfIf/KdCi/Xdi6ohle+7tRFxXcl+sK+e9rfgje1FYfsrOcjkCeUoHh0k4WUGiIqR+9f1 mtag==
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=wtsbF7Ozh4Jjh8v4ncbDQx1wSSIyTQCr5vYMGTjmdio=; b=jr50JIlZXaiGSgXw1wvWYb+nUjJkGxbuv+AMJqLHJre7qXluvme0jzyaTt8yVm5DHu 9fmG2jWzgn0T6DiKLKVAfLUR0jocZfAx4KPM8oBeHBykDVY2G/YmNPGzTkDMPcirHBbu C8+aFhhcDXaaICBAvQMI/fCriZOAnRyEIzc31zxDYXUwcNGi7vLu1R597Onn7QMQI7Ua wzkg46tKF1jSodCF1bJ2diDjKMn6riZ76c7xlSPZjfdJY0T9BxfEhmvmOG1yDyD+vfNm BZE/wsYhgUfGVrWDe5Xw+N4WECzWwPHq+MN+EFg1h8DHrBFYisUTERX+fwtP9Yey//qg nBxQ==
X-Gm-Message-State ALoCoQkfAiGw8ApNlf86BFTmzyTezW5Ft2hhXn0DNooDcCW+6vW/Vd5NmZ3l8Zd2w5BWmIHtICpTCZ+kq+czyRmmXn8FotzjAw==
X-Received by 10.25.153.79 with SMTP id b76mr42439139lfe.102.1452624537344; Tue, 12 Jan 2016 10:48:57 -0800 (PST)
In-Reply-To <n73dc3$jcn$1@ger.gmane.org>
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:101568

Show key headers only | View raw


On Tue, Jan 12, 2016 at 3:32 PM, Peter Otten <__peter__@web.de> wrote:
>
> If there is exactly one item you can unpack:
>
>>>> d = {"Wilf's Cafe": 1}
>>>> k, = d.values()
>>>> k
> 1
>

I personally don't like that trailing comma, it just looks wrong
there. But this is very neat.

-- 
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