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


Groups > comp.lang.python > #101557

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 15:18:01 -0200
Lines 5
Message-ID <mailman.74.1452619122.13488.python-list@python.org> (permalink)
References <f2711b57-7b11-4fd5-8bab-a3e8581177b5@googlegroups.com> <n73c6f$uec$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de hc0X/bgg9eRQDzqHsZBe5AiljXTq5qqVJHO69V5q/7hw==
Return-Path <mafagafogigante@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.070
X-Spam-Evidence '*H*': 0.89; '*S*': 0.03; 'anyway.': 0.04; 'subject:Python': 0.05; 'subject:getting': 0.07; 'pythonic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'dictionary': 0.29; 'subject:/': 0.30; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'does': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'skip:n 10': 0.62; 'intentions': 0.84; 'subject:value': 0.84; 'trick.': 0.84; 'anymore,': 0.95
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=tBBi7x11YN6mDDh4iM2Cor6AHo4EvLqaajlkPNTfI0w=; b=LZvsD/ncI2s8v1SaJj8KCMnNkp8rikVX1lgj8YSLRJyhRw99QzqsdINvi0DJGukHGg T/fApTLuaPr9W2/60WJj1hQ5b+d3tfLh2rD+r0ReRMDZA6yBmE80cktrGWTEpwfNQmg5 oDQe+Bm7zklwds09FFwp2p90Vr4DCT2mLe1ZNrETDmIdn9CWZ9I+S2vuAOBBey4qiWhD nLKHtQNt0q4rWUR7V/4xt/iQ4YanYHS5zJHDOgFwCFJHv5ldtAkeqYKKtDZMtM9leWZH u1ctNgqJshEVowF3Gs/lmy1do5NcT2sKQ5JBF0W7yHRa73cLbN6/y3ShLZ7DAPhPgsn7 ap4g==
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=tBBi7x11YN6mDDh4iM2Cor6AHo4EvLqaajlkPNTfI0w=; b=BCGhT2hK5kDWvJBJJLSlphaNiZ4yipPPuKxTnU6ZBS7FYSTWgNVmmDYQjdne40J2+O vpX/dU6zsEmlQJaWljRJ/sdcPkX6xzlhYOBpQiaWavEkqBBsIxeXPTqC3fdPpP6k+jo2 1I/x5KmqS+/C7Py1L1BouRzJX7U0cmfcONK1U6EKEt3/pcOreGp8Q4ILOZuM7TKe4laB 7wIsllOfK5rdyvidMjCY11ARiz11Q6ofXnsMcPqhFgfQul0ZhFIzU8zDlGLMvbA5kQtZ 4Hc8znm/Vy04debhcQ7BXBQorvzezUwtRA7yPf+imDRQhEwuWPLQktnFOKbmUoXzFwBi 5UkA==
X-Gm-Message-State ALoCoQm3Mq3Wm4EulUcSazEotFjBf39A/FbwWgm3WBi4xwsvJiGPm4LbCQsdldiHW7bkAYFoe9taUHwtxRkLJaEF00lMeeYtJw==
X-Received by 10.25.141.129 with SMTP id p123mr24354596lfd.65.1452619120684; Tue, 12 Jan 2016 09:18:40 -0800 (PST)
In-Reply-To <n73c6f$uec$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:101557

Show key headers only | View raw


Intentions aside, next(iter(...)) seems the most pythonic you can get
about this anyway.

Just in case you happen not to need the dictionary anymore,
d.popitem()[1] does the trick.

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