Path: csiph.com!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!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; 'subject:Python': 0.05; 'mrab': 0.05; '-1,': 0.09; 'bounds.': 0.09; 'failure.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'index': 0.13; 'bound.': 0.16; 'nearest': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'specify': 0.27; 'function': 0.28; 'for,': 0.29; 'array': 0.29; 'e.g.': 0.30; 'returned': 0.32; 'received:comcast.net': 0.33; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'why': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'complement': 0.66 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Random832 Subject: Re: Python handles globals badly. Date: Tue, 08 Sep 2015 20:02:24 -0400 References: <86fa425b-d660-45ba-b0f7-3beebdec8e14@googlegroups.com> <55EE9EEC.1060907@rece.vub.ac.be> <55EF1DD9.8080705@mrabarnett.plus.com> <55EF6D3B.6030106@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain X-Gmane-NNTP-Posting-Host: c-68-39-72-44.hsd1.in.comcast.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:7ylN9boYyFLErWV0kZtFiQN+Cxc= 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: , Newsgroups: comp.lang.python Message-ID: Lines: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441758354 news.xs4all.nl 23724 [2001:888:2000:d::a6]:46591 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96152 MRAB writes: > If you're allowed to specify both bounds, why would you be forbidden > from negative ones? It makes it non-obvious what value should be returned from e.g. search methods that return a negative number on failure. .NET's IndexOf function returns -1, but MaxValue if the array has a negative bound. BinarySearch returns the complement of the nearest index to the value you were searching for, which requires some gymnastics if you want to make use of it for an array that has negative and positive bounds.