Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-06 Thread Georg Brandl
Steve Holden wrote: >> * I acknowledge that Python *code* is almost certainly going to be edited in >> a >> left-to-right text editor, because it's an English-based programming >> language. >> But the strings that string methods like partition() and rpartition() are >> used >> with are quite

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-06 Thread Steve Holden
Nick Coghlan wrote: > Phillip J. Eby wrote: > >>At 04:55 PM 9/5/2006 -0400, Barry Warsaw wrote: >> >>>On Sep 5, 2006, at 4:43 PM, Jim Jewett wrote: >>> >>> I think I finally figured out where Raymond is coming from. For Raymond, "head" is where he started processing -- for rpartition,

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-06 Thread Nick Coghlan
Phillip J. Eby wrote: > At 04:55 PM 9/5/2006 -0400, Barry Warsaw wrote: >> On Sep 5, 2006, at 4:43 PM, Jim Jewett wrote: >> >>> I think I finally figured out where Raymond is coming from. >>> >>> For Raymond, "head" is where he started processing -- for rpartition, >>> this is the .endswith part. >

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-06 Thread Steve Holden
Raymond Hettinger wrote: [...] > That's fine with me. I accept there will always be someone who stands > on their head [...] You'd have to be some kind of contortionist to stand on your head. willfully-misunderstanding-ly y'rs - steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Ho

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Phillip J. Eby
At 02:08 AM 9/6/2006 +0100, David Hopwood wrote: >Barry Warsaw wrote: > > The bias with these terms is clearly the English left-to-right > > order. Actually, that brings up an interesting question: what would > > happen if you called rpartition on a unicode string representing > > Hebrew, Arabic,

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread David Hopwood
Barry Warsaw wrote: > The bias with these terms is clearly the English left-to-right > order. Actually, that brings up an interesting question: what would > happen if you called rpartition on a unicode string representing > Hebrew, Arabic, or other RTL language? Do partition and rpartition

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
See, for me, it's all about the results of the operation, not how the results are (supposedly) used. The way I think about it is that I've got some string and I'm looking for some split point within that string. That split point is clearly the "middle" (but "sep" works too) and every

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Phillip J. Eby
At 04:55 PM 9/5/2006 -0400, Barry Warsaw wrote: >On Sep 5, 2006, at 4:43 PM, Jim Jewett wrote: > > > I think I finally figured out where Raymond is coming from. > > > > For Raymond, "head" is where he started processing -- for rpartition, > > this is the .endswith part. > > > > For me, "head" is th

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sep 5, 2006, at 4:43 PM, Jim Jewett wrote: > I think I finally figured out where Raymond is coming from. > > For Raymond, "head" is where he started processing -- for rpartition, > this is the .endswith part. > > For me, "head" is the start of the

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Jim Jewett
I think I finally figured out where Raymond is coming from. For Raymond, "head" is where he started processing -- for rpartition, this is the .endswith part. For me, "head" is the start of the data structure -- always the .startswith part. We won't resolve that with anything suggesting a sequent

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sep 5, 2006, at 4:13 PM, Raymond Hettinger wrote: > Tim Peters wrote: > >>upto, sep, rest >> >> in whatever order they apply. >> > In the rpartition case, that would be (rest, sep, upto) which seems a > bit cryptic. > > We need some choice of w

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
Tim Peters wrote: >upto, sep, rest > >in whatever order they apply. > In the rpartition case, that would be (rest, sep, upto) which seems a bit cryptic. We need some choice of words that clearly mean: * the chopped-off snippet (guaranteed to not contain the separator) * the separator if f

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Paul Moore
On 9/5/06, Tim Peters <[EMAIL PROTECTED]> wrote: > upto, sep, rest > > in whatever order they apply. I think of a partition-like function as > starting at some position and matching "up to" the first occurence of > the separator (be that left or right or diagonally, "up to" is > relative to th

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Tim Peters
upto, sep, rest in whatever order they apply. I think of a partition-like function as starting at some position and matching "up to" the first occurence of the separator (be that left or right or diagonally, "up to" is relative to the search direction), and leaving "the rest" alone. The docs

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
Ron Adam wrote: >I hope this discussion is only about the words used and the >documentation and not about the actual order of what is received. I >would expect both the following should be true, and it is the current >behavior. > > ''.join(s.partition(sep)) -> s > ''.join(s.rpartition(sep)

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Ron Adam
Raymond Hettinger wrote: > Another thought is that strings don't really have a left and right. > They have a beginning and end. The left/right or top/bottom distinction > is culture specific. Well, it should have been epartition() and not rpartition() in that case. ;-) Is python ever edite

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sep 5, 2006, at 2:32 PM, Raymond Hettinger wrote: > Another thought is that strings don't really have a left and right. > They have a beginning and end. The left/right or top/bottom > distinction > is culture specific. For the target of the met

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Ron Adam
Ron Adam wrote: Correcting myself... > I hope this discussion is only about the words used and the > documentation and not about the actual order of what is received. I > would expect both the following should be true, and it is the current > behavior. > > ''.join(s.partition(sep)) -> s >

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Ron Adam
Michael Chermside wrote: > Jim Jewett writes: >> This change [in docs] looks wrong: >> >> PyDoc_STRVAR(rpartition__doc__, >> -"S.rpartition(sep) -> (head, sep, tail)\n\ >> +"S.rpartition(sep) -> (tail, sep, head)\n\ > > Raymond Hettinger replies: >> It is correct. There may be some confusion in t

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
Jim Jewett wrote: > > Another possibility is data (for head/tail) and unparsed (for rest). > >S.partition(sep) -> (data, sep, unparsed) >S.rpartition(sep) -> (unparsed, sep, data) This communicates very little about the ordering of the return tuple. Beware of overly general terms like

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Jiwon Seo
On 9/5/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On Sep 5, 2006, at 2:06 PM, Raymond Hettinger wrote: > > >> Then shouldn't rpartition be S.rpartition(sep) -> (rest, sep, tail) > > > > Gads, the cure is worse than the disease. > > > > car and

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread John J Lee
On Tue, 5 Sep 2006, Fred L. Drake, Jr. wrote: > On Tuesday 05 September 2006 13:24, Michael Chermside wrote: > > How about something like this: > > > > S.partition(sep) -> (head, sep, tail) > > S.rpartition(sep) -> (tail, sep, rest) > > I think I prefer: > >S.partition(sep) -> (head, s

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sep 5, 2006, at 2:06 PM, Raymond Hettinger wrote: >> Then shouldn't rpartition be S.rpartition(sep) -> (rest, sep, tail) > > Gads, the cure is worse than the disease. > > car and cdr are starting to look pretty good ;-) LOL, the lisper in me likes

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Fred L. Drake, Jr.
On Tuesday 05 September 2006 14:02, Jim Jewett wrote: > Then shouldn't rpartition be S.rpartition(sep) -> (rest, sep, tail) Whichever matches reality, sure. I've lost track of the rpartition() result order. --sigh-- > Another possibility is data (for head/tail) and unparsed (for rest). > >

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
> > Then shouldn't rpartition be S.rpartition(sep) -> (rest, sep, tail) Gads, the cure is worse than the disease. car and cdr are starting to look pretty good ;-) Raymond ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailma

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Jim Jewett
On 9/5/06, Fred L. Drake, Jr. <[EMAIL PROTECTED]> wrote: > S.partition(sep) -> (head, sep, rest) > S.rpartition(sep) -> (tail, sep, rest) > Here, "rest" is always used for "what remains"; head/tail are somewhat more > clear here I think. Then shouldn't rpartition be S.rpartition(sep) ->

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Fred L. Drake, Jr.
On Tuesday 05 September 2006 13:46, Raymond Hettinger wrote: > Changing to left/sep/right will certainly disambiguate questions about left/right is definately not helpful. It's also ambiguous in the case of .rpartition(), where left and right in the input and result are different. > the order

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sep 5, 2006, at 1:46 PM, Raymond Hettinger wrote: >> ISTM this is just begging for newbie (and maybe not-so-newbie) >> confusion. Why not just document both as returning (left, sep, >> right) which seems the most obvious description of what

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Fred L. Drake, Jr.
On Tuesday 05 September 2006 13:24, Michael Chermside wrote: > How about something like this: > > S.partition(sep) -> (head, sep, tail) > S.rpartition(sep) -> (tail, sep, rest) I think I prefer: S.partition(sep) -> (head, sep, rest) S.rpartition(sep) -> (tail, sep, rest) Here

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
> ISTM this is just begging for newbie (and maybe not-so-newbie) > confusion. Why not just document both as returning (left, sep, > right) which seems the most obvious description of what the methods > return? I'm fine with that (though it's a little sad that we think the rather basic co

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sep 5, 2006, at 1:10 PM, Raymond Hettinger wrote: >> This change looks wrong: >> >> PyDoc_STRVAR(rpartition__doc__, >> -"S.rpartition(sep) -> (head, sep, tail)\n\ >> +"S.rpartition(sep) -> (tail, sep, head)\n\ >> >> It looks like the code itself do

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Michael Chermside
Jim Jewett writes: > This change [in docs] looks wrong: > > PyDoc_STRVAR(rpartition__doc__, > -"S.rpartition(sep) -> (head, sep, tail)\n\ > +"S.rpartition(sep) -> (tail, sep, head)\n\ Raymond Hettinger replies: > It is correct. There may be some confusion in terminology. Head > and tail do not

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
> > This change looks wrong: > > PyDoc_STRVAR(rpartition__doc__, > -"S.rpartition(sep) -> (head, sep, tail)\n\ > +"S.rpartition(sep) -> (tail, sep, head)\n\ > > It looks like the code itself does the right thing, but I wasn't quite > confident of that. > It is correct. There may be some confusion

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Jim Jewett
> Jim Jewett wrote: > >Why not just change which of the three strings holds the remainder in > >the not-found case? On 9/5/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > That was the only change submitted. > Are you happy with what was checked-in? This change looks wrong: PyDoc_STRVAR(rpart

Re: [Python-Dev] Fwd: Problem withthe API for str.rpartition()

2006-09-05 Thread Raymond Hettinger
Jim Jewett wrote: > >Why not just change which of the three strings holds the remainder in >the not-found case? > > That was the only change submitted. Are you happy with what was checked-in? Raymond ___ Python-Dev mailing list Python-Dev@python.o