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
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
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
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
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
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.
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
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
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
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
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
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,
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
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
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
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
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
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
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
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
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,
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
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
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
[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
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
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
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
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
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
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
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
32 matches
Mail list logo