Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6385

Re: bug in str.startswith() and str.endswith()

From Mel <mwilson@the-wire.com>
Newsgroups comp.lang.python
Subject Re: bug in str.startswith() and str.endswith()
Followup-To comp.lang.python
Date 2011-05-27 09:03 -0400
Organization Aioe.org NNTP Server
Message-ID <iro7fs$9ep$1@speranza.aioe.org> (permalink)
References <4DDEE1C8.6010107@stoneleaf.us> <mailman.2141.1306465246.9059.python-list@python.org>

Followups directed to: comp.lang.python

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: bug in str.startswith() and str.endswith() Terry Reedy <tjreedy@udel.edu> - 2011-05-26 23:00 -0400
  Re: bug in str.startswith() and str.endswith() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-27 03:27 +0000
  Re: bug in str.startswith() and str.endswith() Mel <mwilson@the-wire.com> - 2011-05-27 09:03 -0400

csiph-web