Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Greg Ewing
Josiah Carlson wrote: > One of the issues with the -1 return on find failure is that it is > ambiguous, one must really check for a -1 return. Here's an API that is > non-ambiguous: An alternative would be to return None for not found. It wouldn't solve the problem of people using the return valu

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread John J Lee
On Wed, 23 Aug 2006, Greg Ewing wrote: > Josiah Carlson wrote: > >> One of the issues with the -1 return on find failure is that it is >> ambiguous, one must really check for a -1 return. Here's an API that is >> non-ambiguous: > > An alternative would be to return None for not found. > It wouldn'

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Nick Coghlan
Guido van Rossum wrote: > At today's sprint, one of the volunteers completed a patch to rip out > find() and rfind(), replacing all calls with index()/rindex(). But now > I'm getting cold feet -- is this really a good idea? (It's been listed > in PEP 3100 for a long time, but I haven't thought abou

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Barry Warsaw
I agree with Tim -- if we have to get rid of one of them, let's get rid of index/rindex and keep find/rfind. Catching the exception is much less convenient than testing for -1. -Barry ___ Python-3000 mailing list [email protected] http://mail.

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Guido van Rossum
On 8/23/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > I agree with Tim -- if we have to get rid of one of them, let's get > rid of index/rindex and keep find/rfind. Catching the exception is > much less convenient than testing for -1. But the -1 is very error-prone, as many have experienced. Also

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Steven Bethard
On 8/23/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 8/23/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > > I agree with Tim -- if we have to get rid of one of them, let's get > > rid of index/rindex and keep find/rfind. Catching the exception is > > much less convenient than testing for -1.

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Oleg Broytmann
On Wed, Aug 23, 2006 at 07:20:54AM -0700, Guido van Rossum wrote: > in py3k I > want to rip out lots of "harmless" to make the language smaller. A > smaller language is also a feature, and a very important one -- a > frequent complaint I hear is that over time the language has lost some > of its or

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Guido van Rossum
That's too narrow a view on the language. Surely the built-in types (especially those with direct compiler support, like literal notations) are part of the language. The people who complain most frequently about Python getting too big aren't language designers, they are users (e.g. scientists) and

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Oleg Broytmann
On Wed, Aug 23, 2006 at 08:18:03AM -0700, Guido van Rossum wrote: > That's too narrow a view on the language. I narrowed it by purpose for this discussion. > Surely the built-in types > (especially those with direct compiler support, like literal > notations) are part of the language. And

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wed, 23 Aug 2006 08:18:03 -0700 "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > That's too narrow a view on the language. Surely the built-in types > (especially those with direct compiler support, like literal > notations) are part of the language

[Python-3000] DictMixin (WAS: Droping find/rfind?)

2006-08-23 Thread Steven Bethard
On 8/23/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > Where it comes to the library, I think we ought to concentrate on > reducing duplication. TOOWTDI. Get rid of the User* modules. Generally a good idea, but we still need somewhere to put DictMixin. It's too bad you can't just use the unbound

Re: [Python-3000] DictMixin (WAS: Droping find/rfind?)

2006-08-23 Thread Jim Jewett
On 8/23/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > Where it comes to the library, I think we ought to concentrate on > reducing duplication. TOOWTDI. Get rid of the User* modules. Until it is possible to inherit from multiple extension types, there will be a need to mimic inheritance with del

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread John J Lee
On Wed, 23 Aug 2006, John J Lee wrote: [...] >> An alternative would be to return None for not found. >> It wouldn't solve the problem of people using the >> return value as a boolean, but at least you'd get >> an exception if you tried to use the not-found value >> as an index. >> >> Or maybe it c

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Steven Bethard
On 8/23/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > I agree with Tim -- if we have to get rid of one of them, let's get > rid of index/rindex and keep find/rfind. Catching the exception is > much less convenient than testing for -1. Could you post a simple example or two? I keep imagining thin

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Josiah Carlson
"Steven Bethard" <[EMAIL PROTECTED]> wrote: > > On 8/23/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > > I agree with Tim -- if we have to get rid of one of them, let's get > > rid of index/rindex and keep find/rfind. Catching the exception is > > much less convenient than testing for -1. > > Co

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Steven Bethard
Steven Bethard wrote: > Could you post a simple example or two? Josiah Carlson wrote: > index = text.find(...) > if index >= 0: > ... > [snip] > index = 0 > while 1: > index = text.find(..., index) > if index == -1: > break > ... > Thank

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Paul Prescod
Just throwing it out but what about something like:found, index = text.index("abc")if found:   doSomething(index)If you were confident that the index was in there you would do something more like this: something = text[text.index("abc")[1]:](although there are clearer ways to do that)On 8/23/06, St

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Georg Brandl
Steven Bethard wrote: > Steven Bethard wrote: >> Could you post a simple example or two? > > Josiah Carlson wrote: >> index = text.find(...) >> if index >= 0: >> ... >> > [snip] >> index = 0 >> while 1: >> index = text.find(..., index) >> if index == -1: >>

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Georg Brandl
Paul Prescod wrote: > Just throwing it out but what about something like: > > found, index = text.index("abc") > > if found: >doSomething(index) -1. str.index()'s semantics should not be different from list.index(). Georg ___ Python-3000 mailing

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Josiah Carlson
"Steven Bethard" <[EMAIL PROTECTED]> wrote: > Steven Bethard wrote: > > Could you post a simple example or two? > > Josiah Carlson wrote: > > index = text.find(...) > > if index >= 0: > > ... > > > [snip] > > index = 0 > > while 1: > > index = text.find(..., index)

Re: [Python-3000] [Python-Dev] What should the focus for 2.6 be?

2006-08-23 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > And yet offense is taken. Have you watched the video of my Py3k talk? > Search for it on Google Video. I spent some time yesterday and watched it. All I was proposing is that similar to Perl 5 and 6, users of Python 2.x may not feel an overwhelmin

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread BJörn Lindqvist
On 8/23/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > or even > > index = 0 > while 1: > index = text.find(..., index) > if index == -1: > break > ... > compared with > > index = 0 > while 1: > try: > index = text.index(...,

Re: [Python-3000] find -> index patch

2006-08-23 Thread Jack Diederich
On Wed, Aug 23, 2006 at 02:18:59PM -0700, Guido van Rossum wrote: > Here's the patch (by Hasan Diwan, BTW) for people's perusal. It just > gets rid of all *uses* of find/rfind from Lib; it doesn't actually > modify stringobject.c or unicodeobject.c. It doesn't use > [r]partition()'; someone could l

Re: [Python-3000] find -> index patch

2006-08-23 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > Here's the patch (by Hasan Diwan, BTW) for people's perusal. It just > gets rid of all *uses* of find/rfind from Lib; it doesn't actually > modify stringobject.c or unicodeobject.c. It doesn't use > [r]partition()'; someone could look for opportuniti

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Josiah Carlson
"BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > > On 8/23/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > > or even > > > > index = 0 > > while 1: > > index = text.find(..., index) > > if index == -1: > > break > > ... > > compared with > > > > in

Re: [Python-3000] find -> index patch

2006-08-23 Thread Hasan Diwan
On 23/08/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: ...that looks to have been done by a script, it has inconsistant stylecompared to the code it replaces, etc.I made the minimal change that implements the functionality suggested, in terms of find/rfind, they return -1. The least painful way to

Re: [Python-3000] find -> index patch

2006-08-23 Thread Georg Brandl
Josiah Carlson wrote: > "Guido van Rossum" <[EMAIL PROTECTED]> wrote: >> Here's the patch (by Hasan Diwan, BTW) for people's perusal. It just >> gets rid of all *uses* of find/rfind from Lib; it doesn't actually >> modify stringobject.c or unicodeobject.c. It doesn't use >> [r]partition()'; someone

Re: [Python-3000] find -> index patch

2006-08-23 Thread Josiah Carlson
Georg Brandl <[EMAIL PROTECTED]> wrote: > > Josiah Carlson wrote: > > "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > >> Here's the patch (by Hasan Diwan, BTW) for people's perusal. It just > >> gets rid of all *uses* of find/rfind from Lib; it doesn't actually > >> modify stringobject.c or unico

Re: [Python-3000] find -> index patch

2006-08-23 Thread Josiah Carlson
"Hasan Diwan" <[EMAIL PROTECTED]> wrote: > On 23/08/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > > > ...that looks to have been done by a script, it has inconsistant style > > compared to the code it replaces, etc. > > > > I made the minimal change that implements the functionality suggested

Re: [Python-3000] [Python-Dev] What should the focus for 2.6 be?

2006-08-23 Thread Terry Reedy
"Josiah Carlson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The intent of my post was to say that all of us want Py3k to succeed, I should hope that we all do. > but I believe that in order for it to succeed that breakage from the 2.x > series should be gradual, in a similar

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Terry Reedy
"Brian Holmes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Even after reading Terry Reedy's arguments, I don't see why we need to > >remove this option. Since this is my first post in this current thread, you either meant someone else or are remembering my posts about in- and

Re: [Python-3000] find -> index patch

2006-08-23 Thread Jack Diederich
On Wed, Aug 23, 2006 at 02:18:59PM -0700, Guido van Rossum wrote: > Here's the patch (by Hasan Diwan, BTW) for people's perusal. It just > gets rid of all *uses* of find/rfind from Lib; it doesn't actually > modify stringobject.c or unicodeobject.c. It doesn't use > [r]partition()'; someone could l

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Jim Jewett
On 8/23/06, Terry Reedy <[EMAIL PROTECTED]> wrote: > 2. change find()'s error return to None, and remove index(); +1 It is particularly unfortunate that the error code of -1 is a valid index. >>> substring = string[string.find(marker):] will silently produce garbage. > or possibly conside

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Greg Ewing
Josiah Carlson wrote: > Given search as a potential replacement, about the only question is > whether count should default to sys.maxint or 1. Do you think that there will be many use cases for count values *other* than 1 or sys.maxint? If not, it might be more sensible to have two functions, sea

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Delaney, Timothy (Tim)
Nick Coghlan wrote: > I also like Josiah's idea of replacing find() with a search() method > that returned an iterator of indices, so that you can do: > > for idx in string.search(sub): > # Process the indices (if any) Need to be careful with this - the original search proposal returned a li

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Josiah Carlson
"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> wrote: > > Nick Coghlan wrote: > > > I also like Josiah's idea of replacing find() with a search() method > > that returned an iterator of indices, so that you can do: > > > > for idx in string.search(sub): > > # Process the indices (if any) > >

Re: [Python-3000] [Python-Dev] What should the focus for 2.6 be?

2006-08-23 Thread Josiah Carlson
"Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Josiah Carlson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > The intent of my post was to say that all of us want Py3k to succeed, > > I should hope that we all do. > > > but I believe that in order for it to succeed that breakage

Re: [Python-3000] [Python-Dev] What should the focus for 2.6 be?

2006-08-23 Thread martin
Zitat von Josiah Carlson <[EMAIL PROTECTED]>: > > To the contrary, you seem to have a basic disagreement with the plan to > > make all the core language changes at once and to clear the decks of old > > baggage so we can move forward with a learner language that is a bit easier > > to learn and re

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Guido van Rossum
I don't find the current attempts to come up with a better substring search API useful. We did a lot of thinking about this not too long ago, and the result was the addition of [r]partition() to 2.5 and the intent to drop [r]find() from py3k as both redundant with [r]index() and error-prone (I thi

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Brian Holmes
On 8/23/06, Terry Reedy <[EMAIL PROTECTED]> wrote: "Brian Holmes" <[EMAIL PROTECTED]> wrote in messagenews:[EMAIL PROTECTED]>Even after reading Terry Reedy's arguments, I don't see why we need to > >remove this option.Since this is my first post in this current thread, you either meantsomeone else

Re: [Python-3000] [Python-Dev] What should the focus for 2.6 be?

2006-08-23 Thread Talin
Josiah Carlson wrote: > "Terry Reedy" <[EMAIL PROTECTED]> wrote: >> "Josiah Carlson" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> The intent of my post was to say that all of us want Py3k to succeed, >> I should hope that we all do. >> >>> but I believe that in order for it t

Re: [Python-3000] Droping find/rfind?

2006-08-23 Thread Josiah Carlson
Greg Ewing <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > Given search as a potential replacement, about the only question is > > whether count should default to sys.maxint or 1. > > Do you think that there will be many use cases for > count values *other* than 1 or sys.maxint? If not, >

Re: [Python-3000] [Python-Dev] What should the focus for 2.6 be?

2006-08-23 Thread Josiah Carlson
[EMAIL PROTECTED] wrote: > > Zitat von Josiah Carlson <[EMAIL PROTECTED]>: > > > > To the contrary, you seem to have a basic disagreement with the plan to > > > make all the core language changes at once and to clear the decks of old > > > baggage so we can move forward with a learner language t

Re: [Python-3000] find -> index patch

2006-08-23 Thread Steven Bethard
On 8/23/06, Jack Diederich <[EMAIL PROTECTED]> wrote: > On Wed, Aug 23, 2006 at 02:18:59PM -0700, Guido van Rossum wrote: > > Here's the patch (by Hasan Diwan, BTW) for people's perusal. It just > > gets rid of all *uses* of find/rfind from Lib; it doesn't actually > > modify stringobject.c or unic