Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: [beginner] What's wrong? Date: Sat, 9 Apr 2016 00:07:08 +0100 Lines: 39 Message-ID: References: <99234e90-fcd4-4a05-b97f-b47228dde20c@googlegroups.com> <1f3a6628-863c-4e92-aa47-e5b3a80baf04@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de /Z7kUKKg8gOv0mhiQNPmpg5cYpyKFCrDBGxor6SCyJgg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'from:addr:yahoo.co.uk': 0.05; 'friday,': 0.07; 'works.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; "they've": 0.09; 'zero.': 0.09; 'python': 0.10; '2016': 0.16; '21)': 0.16; 'ass': 0.16; 'holy': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:beginner': 0.16; 'wrote:': 0.16; 'language': 0.19; 'subject:] ': 0.19; '>>>': 0.20; 'saying': 0.22; 'lawrence': 0.22; 'bit': 0.23; 'slightly': 0.23; 'header:In-Reply- To:1': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'executing': 0.27; 'correct': 0.28; 'actual': 0.28; 'adequate': 0.29; "i'm": 0.30; 'certainly': 0.30; "can't": 0.32; 'language.': 0.32; 'run': 0.33; 'michael': 0.33; 'list': 0.34; "isn't": 0.35; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'received:org': 0.37; 'thought': 0.37; 'wrong': 0.38; 'why': 0.39; 'enough': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'high': 0.60; 'care': 0.60; 'your': 0.60; 'email addr:gmail.com': 0.62; 'charset:windows-1252': 0.62; 'times': 0.63; 'our': 0.64; '20,': 0.66; 'everybody': 0.67; 'gotten': 0.76; 'improved.': 0.84; 'mistakes.': 0.84; 'pythonistas,': 0.84; 'utc-7,': 0.84; 'mistake': 0.91; 'step.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 80.234.134.43 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-Reply-To: <1f3a6628-863c-4e92-aa47-e5b3a80baf04@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <99234e90-fcd4-4a05-b97f-b47228dde20c@googlegroups.com> <1f3a6628-863c-4e92-aa47-e5b3a80baf04@googlegroups.com> Xref: csiph.com comp.lang.python:106711 On 08/04/2016 23:59, sohcahtoa82@gmail.com wrote: > On Friday, April 1, 2016 at 3:57:40 PM UTC-7, Mark Lawrence wrote: >> On 01/04/2016 23:44, sohcahtoa82@gmail.com wrote: >>> On Friday, April 1, 2016 at 3:10:51 PM UTC-7, Michael Okuntsov wrote: >>>> Nevermind. for j in range(1,8) should be for j in range(8). >>> >>> I can't tell you how many times I've gotten bit in the ass with that off-by-one mistake whenever I use a range that doesn't start at zero. >>> >>> I know that if I want to loop 10 times and I either want to start at zero or just don't care about the actual number, I use `for i in range(10)`. But if I want to loop from 10 to 20, my first instinct is to write `for i in range(10, 20)`, and then I'm left figuring out why my loop isn't executing the last step. >>> >> >> "First instinct"? "I expected"? The Python docs might not be perfect, >> but they were certainly adequate enough to get me going 15 years ago, >> and since then they've improved. So where is the problem, other than >> failure to RTFM? >> >> -- >> My fellow Pythonistas, ask not what our language can do for you, ask >> what you can do for our language. >> >> Mark Lawrence > > Holy hell, why such an aggressive tone? > > I understand how range(x, y) works. It's just a simple mistake that I frequently do it wrong and have to correct it after the first time I run it. It's not like I'm saying that the implementation needs to change. I'm just saying that if I want to loop from 10 to 20, my first thought is to use range(10, 20). It is slightly unintuitive. > > *YES*, I know it is wrong. *YES*, I understand why the correct usage would be range(10, 21) to get that list from 10 to 20. > > Get off your high horse. Not everybody is like you and has been using Python for 15 years and apparently never makes mistakes. > *plonk* -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence