Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-07-01 Thread Alan Isaac
A.T.Hofkamp wrote: > Hmm, maybe numbers in sets are broken then? a = 12345 b = 12345 a == b > > True > a is b > > False > set([a,b]) > > set([12345]) > > Numbers and my Car2 objects behave the same w.r.t. '==' and 'is', yet I get a > set with 1 number, and a set with 2 car

Re: equality & comparison by default

2007-06-29 Thread A.T.Hofkamp
On 2007-06-29, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Thu, 28 Jun 2007 11:38:56 -0300, A.T.Hofkamp <[EMAIL PROTECTED]> > escribió: > >> The point I intended to make was that having a default __hash__ method on >> objects give weird results that not everybody may be aware of. >> In addi

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-29 Thread Steve Holden
A.T.Hofkamp wrote: > On 2007-06-29, Steve Holden <[EMAIL PROTECTED]> wrote: >> Just the same there are sound reasons for it, so I'd prefer to see you >> using "counterintuitive" or "difficult to fathom" rather than "broken" >> and "wrong". > > You are quite correct, in the heat of typing an answ

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-29 Thread A.T.Hofkamp
On 2007-06-28, Roy Smith <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > "A.T.Hofkamp" <[EMAIL PROTECTED]> wrote: > >> In object oriented programming, objects are representations of values, and >> the >> system shouldn't care about how many instances there are of some value, just >

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-29 Thread A.T.Hofkamp
On 2007-06-29, Steve Holden <[EMAIL PROTECTED]> wrote: > Just the same there are sound reasons for it, so I'd prefer to see you > using "counterintuitive" or "difficult to fathom" rather than "broken" > and "wrong". You are quite correct, in the heat of typing an answer, my wording was too stron

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread mmanns
On Fri, 29 Jun 2007 00:47:16 -0300 "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > __hash__ and equality tests are used by the dictionary > implementation, and the default implementation is OK for immutable > objects. That is probably why inf == inf yields True. In this unique case, I do not lik

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread Gabriel Genellina
En Thu, 28 Jun 2007 11:38:56 -0300, A.T.Hofkamp <[EMAIL PROTECTED]> escribió: > The point I intended to make was that having a default __hash__ method on > objects give weird results that not everybody may be aware of. > In addition, to get useful behavior of objects in sets one should > overr

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread Steve Holden
A.T.Hofkamp wrote: > On 2007-06-28, Alan Isaac <[EMAIL PROTECTED]> wrote: >> A.T.Hofkamp wrote: >> >> a = Car2(123) >> b = Car2(123) >> a == b >>> True >>> >> set([a,b]) >>> set([Car2(123), Car2(123)]) >>> >>> I get a set with two equal cars, something that never happens with a set

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "A.T.Hofkamp" <[EMAIL PROTECTED]> wrote: > In object oriented programming, objects are representations of values, and the > system shouldn't care about how many instances there are of some value, just > like numbers in math. Every instance with a certain value is t

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread A.T.Hofkamp
On 2007-06-28, Alan Isaac <[EMAIL PROTECTED]> wrote: > A.T.Hofkamp wrote: > >a = Car2(123) >b = Car2(123) >a == b >> >> True >> >set([a,b]) >> >> set([Car2(123), Car2(123)]) >> >> I get a set with two equal cars, something that never happens with a set >> my math teacher once to

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread Alan Isaac
A.T.Hofkamp wrote: a = Car2(123) b = Car2(123) a == b > > True > set([a,b]) > > set([Car2(123), Car2(123)]) > > I get a set with two equal cars, something that never happens with a set > my math teacher once told me. Then your math teacher misspoke. You have two different car

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread A.T.Hofkamp
On 2007-06-27, Alex Martelli <[EMAIL PROTECTED]> wrote: > A.T.Hofkamp <[EMAIL PROTECTED]> wrote: > >> I think that again now with the default implementation of the >> object.__eq__ and object.__hash__ methods. I believe these methods should >> not exist until the programmer explicitly defines th

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-27 Thread Erik Max Francis
Aahz wrote: > In article <[EMAIL PROTECTED]>, > Alex Martelli <[EMAIL PROTECTED]> wrote: >> In Python 3000, ordering comparisons will not exist by default (sigh, a >> modest loss of practicality on the altar of purity -- ah well, saw it >> coming, ever since complex numbers lost ordering compariso

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-27 Thread Aahz
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: > >In Python 3000, ordering comparisons will not exist by default (sigh, a >modest loss of practicality on the altar of purity -- ah well, saw it >coming, ever since complex numbers lost ordering comparisons), but >equality an