Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Bernardo Sulzbach 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: References: <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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101626 On Tue, Jan 12, 2016 at 11:29 PM, Steven D'Aprano 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