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


Groups > comp.lang.python > #51231

Re: Python 3: dict & dict.keys()

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'operator': 0.03; 'subject:Python': 0.06; 'abstraction': 0.09; 'explanation': 0.09; 'literal': 0.09; 'subject:()': 0.09; 'python': 0.11; 'itself.': 0.14; 'random': 0.14; '(sorry,': 0.16; '12:57': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ought': 0.16; 'said.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'normally': 0.19; 'meant': 0.20; 'lets': 0.24; 'fine': 0.24; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'topic': 0.29; "doesn't": 0.30; 'sets': 0.30; 'message- id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'another': 0.32; 'fri,': 0.33; 'comment': 0.34; 'agree': 0.35; 'equal': 0.35; 'good.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'similar': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'expression': 0.60; 'real': 0.63; 'become': 0.64; 'more': 0.64; 'love': 0.65; 'side': 0.67; '26,': 0.68; 'subject: & ': 0.68; 'union': 0.69; 'jul': 0.74; 'leak': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=3eg4Bkdf2DgeNOp2JSn/x/pSt7nL3ke9zgsik2wlYbs=; b=u8CnJHUfVL7VHPhpId5/XxjKPqHbXJjwQnDBmSI00F98xCpgTkShFNB95GpjXjWftF ju7eTBviUaut6QKH+b1++glvOViO1UDztoXxJAk5Ewp7zUJfY/7qqwlLYD+vvne58RG3 /gXojKxwg8Sh2o4IzqlRlFptCAmyOC5k+i2uQdg0mWPYOWftTnqT1h1D4/CBgTrud6SF a7vsYf3HGZNLEWLB3PrZv5euJfb11MMLk1WKmFhZWG83OExJoeykeabPapwi6TfT9cGh 4K1oUEZUqI/+kAZAWRBXpwJUGo7j9lW1Q0wX/hxTyTeH0nBc+ODSiyh3oWZp+bodINL6 bKFQ==
MIME-Version 1.0
X-Received by 10.58.187.4 with SMTP id fo4mr18051174vec.55.1374764876050; Thu, 25 Jul 2013 08:07:56 -0700 (PDT)
In-Reply-To <51f13cc5$0$29971$c3e8da3$5496439d@news.astraweb.com>
References <51EF2AD8.3080105@stoneleaf.us> <ksnrr9$k4t$1@ger.gmane.org> <CAHVvXxQGCFJe7ud+mwh4zhnq5F7xvHJX1pCtGCjMaFtjBwY=iQ@mail.gmail.com> <mailman.5049.1374682931.3114.python-list@python.org> <51f0bc34$0$29971$c3e8da3$5496439d@news.astraweb.com> <mailman.5081.1374732171.3114.python-list@python.org> <51f0d36c$0$29971$c3e8da3$5496439d@news.astraweb.com> <mailman.5087.1374740125.3114.python-list@python.org> <51f0f38b$0$29971$c3e8da3$5496439d@news.astraweb.com> <mailman.5091.1374748472.3114.python-list@python.org> <51f13cc5$0$29971$c3e8da3$5496439d@news.astraweb.com>
Date Fri, 26 Jul 2013 01:07:55 +1000
Subject Re: Python 3: dict & dict.keys()
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5105.1374764885.3114.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1374764885 news.xs4all.nl 15957 [2001:888:2000:d::a6]:36053
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51231

Show key headers only | View raw


On Fri, Jul 26, 2013 at 12:57 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> [ snip lengthy explanation of sets ]
> The union operator ought to
> be symmetrical, a ∪ b should be identical to b ∪ a, but isn't. Another
> leaky abstraction.

Right. I agree with all your theory, which is fine and good. If we had
a "set of real numbers", then each one would be both equal to and
indistinguishable from any other representation of itself. But Python
doesn't work with real numbers. It works with ints and floats and
Fractions and Decimals and Guido-knows-what. (Sorry, I don't normally
talk like that, but the expression begged to be said. :) )

So since Python already lets its abstraction leak a bit for
usefulness, why not retain the exact same leak when working with a
dict? A set is a dict with no values... a dict is a set with extra
payload. They're given very similar literal notation; if they were
meant to be more distinct, why was no alternative symbol used?

(I love how a random side comment can become a topic of its own.)

ChrisA

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


Thread

Re: Python 3: dict & dict.keys() Ethan Furman <ethan@stoneleaf.us> - 2013-07-24 08:57 -0700
  Re: Python 3: dict & dict.keys() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-25 05:48 +0000
    Re: Python 3: dict & dict.keys() Chris Angelico <rosuav@gmail.com> - 2013-07-25 16:02 +1000
      Re: Python 3: dict & dict.keys() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-25 07:27 +0000
        Re: Python 3: dict & dict.keys() Chris Angelico <rosuav@gmail.com> - 2013-07-25 18:15 +1000
          Re: Python 3: dict & dict.keys() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-25 09:44 +0000
            Re: Python 3: dict & dict.keys() Chris Angelico <rosuav@gmail.com> - 2013-07-25 20:34 +1000
              Re: Python 3: dict & dict.keys() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-25 14:57 +0000
                Re: Python 3: dict & dict.keys() Chris Angelico <rosuav@gmail.com> - 2013-07-26 01:07 +1000
    Re: Python 3: dict & dict.keys() Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-07-25 15:22 +0200
    Re: Python 3: dict & dict.keys() Ethan Furman <ethan@stoneleaf.us> - 2013-07-25 06:57 -0700

csiph-web