Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Mel Newsgroups: comp.lang.python Subject: Re: bug in str.startswith() and str.endswith() Followup-To: comp.lang.python Date: Fri, 27 May 2011 09:03:55 -0400 Organization: Aioe.org NNTP Server Lines: 21 Message-ID: References: <4DDEE1C8.6010107@stoneleaf.us> Reply-To: mwilson@the-wire.com NNTP-Posting-Host: V7j4zcmtGzEmG1C7HjXFbg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.4.8 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6385 Terry Reedy wrote: > To me, that says pretty clearly that start and end have to be > 'positions', ie, ints or other index types. So I would say that the > error message is a bug. I see so reason why one would want to use None > rather that 0 for start or None rather than nothing for end. If you're trying to wrap a call to startswith in a function that "looks like" startswith, there's no easy way to pass in the information that your caller wants the default parameters. The case I ran into was def wrapped_range (start, stop=None, span=None): do_some_things() result = range (start, stop, span) # range doesn't(/didn't) accept this return result Tne answer in that case was to take *args as the parameter to wrapped_range and count arguments to distinguish between the different calls to range. Mel.