Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Marco Kaulea Newsgroups: comp.lang.python Subject: Set Operations on Dicts Date: Mon, 8 Feb 2016 10:56:43 +0100 Lines: 19 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 8Fg+Jxev6OL80oBFr4kMRAfF6Wo/lqO4yj/Ntnn6M3JQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.132 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.74; '*S*': 0.00; 'implemented.': 0.09; 'example:': 0.10; 'received:io': 0.16; 'received:psf.io': 0.16; "{'a':": 0.16; 'basically': 0.18; 'received:209.85.214.174': 0.22; 'exists.': 0.22; 'sets': 0.23; 'feature': 0.24; 'message- id:@mail.gmail.com': 0.27; 'operations': 0.31; '[1]': 0.32; 'surprised': 0.33; 'values.': 0.33; 'received:google.com': 0.35; 'should': 0.36; 'needed': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'received:209': 0.38; 'hi,': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.40; 'easy': 0.60; '&': 0.61; 'spend': 0.67; 'worth': 0.67; 'url:v': 0.72; 'url:youtube': 0.73; 'url:watch': 0.78; 'subject:Set': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=xgbJB1V/NLf08qUVVV/1L1XXSck9H1gXrjwSHnpaOto=; b=0rLOjgDoPKxUxi8lhuP+/A2YEtrLYEfRWfBOF2rVjby4DaGFseFQJj2KFfMg2zHA+D IjvqBfNzJTYSdVtKkO/LKsGJSbIGbyW4+qCgZylf33wmI0COEfbYtbggUkXIy4e+OCcd r32ToEC1ib7/zyh34BFxI8q7Pb3M6XbuL1QKpAJUPWk97s6ES7r9KuFaSEtMWhPci7g5 nIzBbGoOJ2ToRB+YxcEbqwa+s0/wY4GEFwiBg+jvkyBtKXYF/LutVqsw4+su566Fc83E ZEjCct0BZ0hHjNuwEVubk7LCUs+LjCAtcN8GLVRBf144K+lGWT4ReLcM/djWMJPccV1H pg2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=xgbJB1V/NLf08qUVVV/1L1XXSck9H1gXrjwSHnpaOto=; b=HR8qd04lh/38TUswwuMKvC9JxFER4/w3LUgXmK6Ibb6PaCYaryhvSEy5THDvtezh3+ dcbayKIRdRrlYpn/are/eBJaqImAsP5JYimMZX47JUgWg4wFqhKEn3FUaQZqNbgH6OKM 00auDjTMsQd3d+DDFZVL82QfPY5LhOUYtUj67B0k+fXC8T7U+dKDjt7HJ52q5MbFvTiB T4QgrlmXFev7RWKYl+2FHlFSHTCgY6Ec6Yq1oP01Rd7owOcbsp0AyAogoi4tw65gzkVL eaX2bkvx3AB2a0++2ZPZS13bcULA2OYKm4hQNLNpJcfwuo75ed1fvI/gro0ajef0d3di NQbw== X-Gm-Message-State: AG10YOSQs3iHyHyVoVtM4LHHkXKWs4ueBM7JtJ7sDh81BA5knGanpoivHKo6T8YdVt4rsa3lusUJ/trq2QzzWw== X-Received: by 10.60.220.230 with SMTP id pz6mr24287646oec.49.1454925423115; Mon, 08 Feb 2016 01:57:03 -0800 (PST) X-Mailman-Approved-At: Mon, 08 Feb 2016 04:57:56 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.21rc2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 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:102652 Hi, In one talk (I think it was [1]) it was described that sets are basically dicts without the values. Therefor it should be easy to apply set operations on dicts, for example: {'a': 123, 'b': 456} & {'a'} => {'a': 123} {'a': 123, 'b': 456} - {'a'} => {'b': 456} This if currently not implemented. Is there a technical reason that this is difficult or are there a lot of corner cases that make it not worth the trouble? I have not spend a lot of time on this, I just needed a feature like that and was surprised that it did not exists. - Marco [1] https://www.youtube.com/watch?v=C4Kc8xzcA68