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 cars. Something is wrong here

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 strong, I am

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 like numbers in

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 answer, my wording was

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-28 Thread Alex Martelli
Bjoern Schliessmann [EMAIL PROTECTED] wrote: ... Mh, strange, I personally like to use this.a in C++, to make clear I use an instance variable. That would be nice, unfortunately your C++ compiler will refuse that, and force you to use this-a instead;-). Many programming shops use naming

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-28 Thread Bjoern Schliessmann
Alex Martelli wrote: Bjoern Schliessmann [EMAIL PROTECTED] wrote: Mh, strange, I personally like to use this.a in C++, to make clear I use an instance variable. That would be nice, unfortunately your C++ compiler will refuse that, and force you to use this-a instead;-). Sure, thanks.

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-28 Thread Lou Pecora
In article [EMAIL PROTECTED], Jorgen Bodde [EMAIL PROTECTED] wrote: I had the same feeling when I started, coming from a C++ background, I forgot about self a lot, creating local copies of what should be an assign to a class instance, or methods that could not be found because I forgot

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 them with a

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 cars in the set, just as

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 told me. Then your math teacher

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 the same

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-28 Thread John Nagle
Alex Martelli wrote: Bjoern Schliessmann [EMAIL PROTECTED] wrote: ... Mh, strange, I personally like to use this.a in C++, to make clear I use an instance variable. That would be nice, unfortunately your C++ compiler will refuse that, and force you to use this-a instead;-). Yes,

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 my math teacher once told me. Then your

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 override

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 like the

Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread [EMAIL PROTECTED]
HI I'm currently using Python. I find that a instance variable must confined with self, for example: class a: def __init__(self): self.aa=10 def bb(self): print self.aa # See .if in c++,I could use aa to change that variable That's a big inconvenience in coding

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: I'm currently using Python. I find that a instance variable must confined with self, for example: class a: def __init__(self): self.aa=10 def bb(self): print self.aa # See .if in c++,I could use aa to change that

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Neil Cerutti
On 2007-06-27, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: HI I'm currently using Python. I find that a instance variable must confined with self, for example: class a: def __init__(self): self.aa=10 def bb(self): print self.aa # See .if in c++,I could use aa to

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread faulkner
On Jun 27, 7:02 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: HI I'm currently using Python. I find that a instance variable must confined with self, for example: class a: def __init__(self): self.aa=10 def bb(self): print self.aa # See .if in c++,I could use

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Roy Smith
faulkner [EMAIL PROTECTED] wrote: http://www.voidspace.org.uk/python/weblog/arch_d7_2006_12_16.shtml#e584 I looked the Selfless Python idea described there, and I think it's a REALLY bad idea. It's a clever hack, but not something I would ever want to see used in production code. Sure, it

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Roy Smith
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: Use a shorter name than `self` or an editor with auto completion. Of the two, I'd strongly vote for the auto completion (assuming you feel the need to solve this problem at all). The name self is so ingrained in most Python programmers minds,

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Sion Arrowsmith
Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-06-27, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From My point,I think this only help python interpreter to deside where to look for. Is there anyone know's how to make the interpreter find instance name space first? Or any way to make

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Jorgen Bodde
I had the same feeling when I started, coming from a C++ background, I forgot about self a lot, creating local copies of what should be an assign to a class instance, or methods that could not be found because I forgot 'self' . Now I am 'kinda' used to it, as every language has some draw backs

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread A.T.Hofkamp
On 2007-06-27, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: HI I'm currently using Python. I find that a instance variable must confined with self, for example: class a: def __init__(self): self.aa=10 def bb(self): print self.aa # See .if in c++,I could use aa to

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: I'm currently using Python. How long have you been using Python? I find that a instance variable must confined with self, for example: class a: def __init__(self): self.aa=10 def bb(self): print self.aa # See .if in c++,I could use aa

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

2007-06-27 Thread Alex Martelli
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 them with a suitable notion of equivalence. Anybody have a

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread John Roth
On Jun 27, 5:02 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: HI I'm currently using Python. I find that a instance variable must confined with self, for example: class a: def __init__(self): self.aa=10 def bb(self): print self.aa # See .if in c++,I could use

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Bruno Desthuilliers
Jorgen Bodde a écrit : I had the same feeling when I started, coming from a C++ background, I forgot about self a lot, creating local copies of what should be an assign to a class instance, or methods that could not be found because I forgot 'self' . Now I am 'kinda' used to it, as every

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 and

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread John Nagle
Bruno Desthuilliers wrote: Jorgen Bodde a écrit : But, what about something in between like only using the dot (.) for a shorter notation? How about Mavis Beacon Teaches Typing? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Andy Freeman
On Jun 27, 2:54 pm, John Nagle [EMAIL PROTECTED] wrote: But, what about something in between like only using the dot (.) for a shorter notation? How about Mavis Beacon Teaches Typing? How about no wouldn't it be better suggestions until at least three months after the suggester has

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 comparisons), but