Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'operator': 0.03; 'definitions.': 0.07; 'skip:` 10': 0.07; 'currently,': 0.09; 'differently.': 0.09; 'implements': 0.09; 'imply': 0.09; 'def': 0.12; 'behave': 0.16; 'magic': 0.16; 'operator.': 0.16; 'parts,': 0.16; 'subject:`': 0.16; 'discussions': 0.16; 'appropriate': 0.16; 'thanks,': 0.17; 'do.': 0.18; 'module': 0.19; 'translated': 0.19; 'not,': 0.20; 'fit': 0.20; 'seems': 0.21; 'appears': 0.22; 'separate': 0.22; 'header :User-Agent:1': 0.23; 'case.': 0.24; 'exists': 0.24; 'mathematical': 0.24; "shouldn't": 0.24; 'skip:` 20': 0.24; '(or': 0.24; 'somewhere': 0.26; 'skip:_ 20': 0.27; 'function': 0.29; 'feature': 0.29; '(this': 0.29; 'related': 0.29; "i'm": 0.30; 'received:132': 0.31; 'anyone': 0.31; 'probably': 0.32; 'implemented': 0.33; 'could': 0.34; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'method': 0.36; 'should': 0.36; 'received:209': 0.37; 'represent': 0.38; 'message- id:@gmail.com': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'most': 0.60; 'name': 0.63; 'more': 0.64; 'believe': 0.68; 'default': 0.69; 'food': 0.72; 'subject:skip:o 10': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=d0yGN1gke1YQaH0TJXsB4W/IdCNtmZySSF+hJdqvzPA=; b=fmR9x6j8enygTJfY2lsYMUE1roqiS5MNgD2i1GjwxBEMRAsHhkpaybk9yXTMT7YpO7 Zc7oPk+qX5sSAnFVtcPwNl8moKWhPFCSjNQrzwIm+tSPu1BTyq8YM3TH/jVIW4YNS4+x q4w6hSWKav38cQpTIpjNf7b2NFe8fSnQD0HXRPBJivat3EFffbrZdzbYb62U8ssilVo7 f4bcag009pluTnGdJhe1ZDRP+6Q+K6fiKQ3fdqRGZSXAVHrCyTqpDtvQ1bQCQOF3Tm4w G6ga1woydanlJp3XuOrFIi2dsMzlt023aLBtlDrAFHzDPJVDnMj5S1/jARrBaOn5ThnI 0nSA== X-Received: by 10.221.0.199 with SMTP id nn7mr11864555vcb.14.1366381632958; Fri, 19 Apr 2013 07:27:12 -0700 (PDT) Date: Fri, 19 Apr 2013 10:27:09 -0400 From: Matthew Gilson User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: python-list@python.org Subject: Feature Request: `operator.not_in` Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366382044 news.xs4all.nl 2221 [2001:888:2000:d::a6]:58061 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43900 I believe that I read somewhere that this is the place to start discussions on feature requests, etc. Please let me know if this isn't the appropriate venue (and what the appropriate venue would be if you know). This request has 2 related parts, but I think they can be considered seperately: 1) It seems to me that the operator module should have a `not_in` or `not_contains` function. It seems asymmetric that there exists a `is_not` function which implements `x is not y` but there isn't a function to represent `x not in y`. 2) I suspect this one might be a little more controversial, but it seems to me that there should be a separate magic method bound to the `not in` operator. Currently, when inspecting the bytecode, it appears to me that `not x in y` is translated to `x not in y` (this supports item 1 slightly). However, I don't believe this should be the case. In python, `x < y` does not imply `not x >= y` because a custom object can do whatever it wants with `__ge__` and `__lt__` -- They don't have to fit the normal mathematical definitions. I don't see any reason why containment should behave differently. `x in y` shouldn't necessarily imply `not x not in y`. I'm not sure if `object` could have a default `__not_contains__` method (or whatever name seems most appropriate) implemented equivalently to: def __not_contains__(self,other): return not self.__contains__(other) If not, it could probably be provided by something like `functools.total_ordering`. Anyway, it's food for thought and I'm interested to see if anyone else feels the same way that I do. Thanks, ~Matt