Re: [Python-Dev] Keep default comparisons - or add a second set?

2006-03-14 Thread Guido van Rossum
On 12/28/05, Robert Brewer <[EMAIL PROTECTED]> wrote: > Noam Raphael wrote: > > I don't think that every type that supports equality > > comparison should support order comparison. I think > > that if there's no meaningful comparison (whether > > equality or order), an exception should be raise

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Noam Raphael
On 12/29/05, Robert Brewer <[EMAIL PROTECTED]> wrote: > > Just to keep myself sane... > > def date_range(start=None, end=None): > if start == None: > start = datetime.date.today() > if end == None: > end = datetime.date.today() > return end

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Robert Brewer
Title: RE: [Python-Dev] Keep default comparisons - or add a second set? Noam Raphael wrote: > I don't think that every type that supports equality > comparison should support order comparison. I think > that if there's no meaningful comparison (whether > equality o

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Adam Olsen
On 12/28/05, Noam Raphael <[EMAIL PROTECTED]> wrote: > On 12/28/05, Adam Olsen <[EMAIL PROTECTED]> wrote: > > Speaking of id, there's no reason why "id(a) == id(b)" has to fail for > > mismatched types in the face of persistence so long as the result of > > id() has the same lifetime as the target

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Noam Raphael
On 12/28/05, Adam Olsen <[EMAIL PROTECTED]> wrote: > I agree for greaterthan and lessthan operators but I'm not convinced > for equality. Consider this in contrast to your example: > >>> a = 1+2j > >>> b = 1+2j > >>> a is b > False > >>> a == b > True > > Complex numbers can't be sorted but they c

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Adam Olsen
On 12/28/05, Noam Raphael <[EMAIL PROTECTED]> wrote: > And another example: > > >>> a = 1+2j > >>> b = 2+1j > >>> a > b > Traceback (most recent call last): > File "", line 1, in > TypeError: no ordering relation is defined for complex numbers > > I came to think that, when forgetting backwards

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Adal Chiriliuc
On Wednesday, December 28, 2005 Noam Raphael wrote: > I came to think that, when forgetting backwards compatibility for a > while, the best thing for comparison operators to do is to raise a > TypeError by default, and work only for types that it makes sense to > compare. I think it is more "explic

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Noam Raphael
And another example: >>> a = 1+2j >>> b = 2+1j >>> a > b Traceback (most recent call last): File "", line 1, in TypeError: no ordering relation is defined for complex numbers I came to think that, when forgetting backwards compatibility for a while, the best thing for comparison operators to d

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-28 Thread Adam Olsen
On 12/27/05, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Tell me: > >>> a = [0] * 3 > >>> b = [0] * 3 > >>> a[0] = b > >>> b[0] = a > > What order should a and b have? More gems: >>> Decimal(3) < 4.0 False >>> Decimal(3) == 3.0 False >>> Decimal(3) > 4.0 True And the pièce de résistance:

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-27 Thread Scott David Daniels
Jim Jewett wrote: > Jim Fulton asked how this canonical ordering > should be defined. > > The obvious answer is "Just like the __lt__ > operator today". But it doesn't actually *need* > to be that sensible, if there are strong reasons > to prefer a simpler ordering. > > The more I think about i

[Python-Dev] Keep default comparisons - or add a second set?

2005-12-27 Thread Jim Jewett
Today, x < y will return a consistent result, even if the two objects are not comparable in any meaningful manner.[*] The current plan for Python 3 is to instead raise TypeError. If this really needs to be changed (and I don't think it does), then there should still be a s

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-20 Thread M.-A. Lemburg
Josiah Carlson wrote: > Jim Fulton <[EMAIL PROTECTED]> wrote: >> Jim Jewett wrote: >>> PEP 3000 now suggests that dropping default comparison has become more >>> than an idle what-if. >>> >>> Unfortunately, one very common use case of comparisons is to get a >>> canonical order. If the order is se

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-20 Thread Josiah Carlson
Jim Fulton <[EMAIL PROTECTED]> wrote: > > Jim Jewett wrote: > > PEP 3000 now suggests that dropping default comparison has become more > > than an idle what-if. > > > > Unfortunately, one very common use case of comparisons is to get a > > canonical order. If the order is sensible, all the bett

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-20 Thread Michael Urman
On 12/19/05, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > Michael Urman <[EMAIL PROTECTED]> wrote: > > Such as sorted(stuff, key=id)? > > I believe that ideally, canonical orderings would be persistant across > sessions. Erm, yes, I totally missed that in Jim's original preferred requirements. An

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-20 Thread Jim Fulton
Jim Jewett wrote: > PEP 3000 now suggests that dropping default comparison has become more > than an idle what-if. > > Unfortunately, one very common use case of comparisons is to get a > canonical order. If the order is sensible, all the better, but that > is not strictly required. One of Pytho

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-19 Thread Josiah Carlson
Michael Urman <[EMAIL PROTECTED]> wrote: > > On 12/19/05, Greg Ewing <[EMAIL PROTECTED]> wrote: > > That would be my preference. Comparison for canonical > > ordering should be a distinct operation with its > > own spelling. > > Such as sorted(stuff, key=id)? I believe that ideally, canonical o

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-19 Thread Michael Urman
On 12/19/05, Greg Ewing <[EMAIL PROTECTED]> wrote: > That would be my preference. Comparison for canonical > ordering should be a distinct operation with its > own spelling. Such as sorted(stuff, key=id)? Michael -- Michael Urman http://www.tortall.net/mu/blog ___

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-19 Thread Greg Ewing
Jim Jewett wrote: > Or, at the very least, promote a > *standard* way to say "just get me a canonical ordering of some sort" That would be my preference. Comparison for canonical ordering should be a distinct operation with its own spelling. Then Guido's > Comparisons other than == and !

Re: [Python-Dev] Keep default comparisons - or add a second set?

2005-12-19 Thread Paul Moore
On 12/19/05, Jim Jewett <[EMAIL PROTECTED]> wrote: > Unfortunately, one very common use case of comparisons is to get a > canonical order. If the order is sensible, all the better, but that > is not strictly required. One of Python's selling points (especially > compared to Java) is that getting

[Python-Dev] Keep default comparisons - or add a second set?

2005-12-19 Thread Jim Jewett
PEP 3000 now suggests that dropping default comparison has become more than an idle what-if. Unfortunately, one very common use case of comparisons is to get a canonical order. If the order is sensible, all the better, but that is not strictly required. One of Python's selling points (especially