Re: dictionary/hash and '1' versus 1

2008-01-08 Thread Piet van Oostrum
> "Diez B. Roggisch" <[EMAIL PROTECTED]> (DBR) wrote: >DBR> So you can also do >DBR> "" + some_object >DBR> However, >DBR> some_object + "" >DBR> or >DBR> 1 + "" >DBR> don't work - the operator is only overloaded on the left argument. There is no problem with 1+"" neither with new Integ

Re: dictionary/hash and '1' versus 1

2008-01-07 Thread Paddy
On Jan 7, 7:26 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of Paddy > > Sent: Monday, January 07, 2008 12:52 PM > > To: [EMAIL PROTECTED] &

RE: dictionary/hash and '1' versus 1

2008-01-07 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Paddy > Sent: Monday, January 07, 2008 12:52 PM > To: python-list@python.org > Subject: Re: dictionary/hash and '1' versus 1 > > Or how using different o

Re: dictionary/hash and '1' versus 1

2008-01-07 Thread Paddy
On Jan 7, 5:09 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > Bingo. Perl has specific operators to establish intent: > > Perl -e "'1' + 1" > > 2 > > Perl -e "'1' . 1" > > 11 > '+' is the operator for addition > '.' is the operator for string concatenation > >

RE: dictionary/hash and '1' versus 1

2008-01-07 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Steven D'Aprano > Sent: Saturday, January 05, 2008 7:01 PM > To: python-list@python.org > Subject: Re: dictionary/hash and '1' versus 1 > > The pro

Re: dictionary/hash and '1' versus 1

2008-01-07 Thread Sion Arrowsmith
<[EMAIL PROTECTED]> wrote: >In Java you can add the number 1 to a string, and have it >automatically converted to string before the string join... What do >you think of that feature? "-%s" % 1 -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ "Frankly I have no feelings towards pe

Re: dictionary/hash and '1' versus 1

2008-01-07 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Paddy: >> Not really, it seems to me to be going the exact opposite way with >> languages with automatic type conversions being seen as not suited for >> larger programs. > > In Java you can add the number 1 to a string, and have it > automatically converted to string

Re: dictionary/hash and '1' versus 1

2008-01-06 Thread Paddy
On Jan 5, 11:07 pm, [EMAIL PROTECTED] wrote: > Paddy: > > > Not really, it seems to me to be going the exact opposite way with > > languages with automatic type conversions being seen as not suited for > > larger programs. > > In Java you can add the number 1 to a string, and have it > automaticall

Re: dictionary/hash and '1' versus 1

2008-01-05 Thread Steven D'Aprano
On Sat, 05 Jan 2008 15:07:10 -0800, bearophileHUGS wrote: > Paddy: >> Not really, it seems to me to be going the exact opposite way with >> languages with automatic type conversions being seen as not suited for >> larger programs. > > In Java you can add the number 1 to a string, and have it auto

Re: dictionary/hash and '1' versus 1

2008-01-05 Thread bearophileHUGS
Paddy: > Not really, it seems to me to be going the exact opposite way with > languages with automatic type conversions being seen as not suited for > larger programs. In Java you can add the number 1 to a string, and have it automatically converted to string before the string join... What do you

Re: dictionary/hash and '1' versus 1

2008-01-05 Thread Paddy
On Jan 4, 3:50 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > From: Stephen Hansen [mailto:[EMAIL PROTECTED] > > Sent: Thursday, January 03, 2008 7:39 PM > > To: Reedick, Andrew > > Cc: [EMAIL PROTECTED] > > Subject: Re: dictionary/hash and

Re: dictionary/hash and '1' versus 1

2008-01-04 Thread Stephen Hansen
> > > A single integer is distinctly different from a sequence of characters > in > > some encoding that may just happen to contain representations of a > > number so they'll hash differently :) > >Depends on the context. The machine encoding may be different, but > in human terms they

RE: dictionary/hash and '1' versus 1

2008-01-04 Thread Reedick, Andrew
> From: Stephen Hansen [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 03, 2008 7:39 PM > To: Reedick, Andrew > Cc: python-list@python.org > Subject: Re: dictionary/hash and '1' versus 1 > > > > Well one important thing to learn while learning Pyt

Re: dictionary/hash and '1' versus 1

2008-01-04 Thread Erik Max Francis
Reedick, Andrew wrote: > As a Perl monkey in the process of learning Python, I just stepped on > the "'1' (string) is not the same as 1 (integer) in regards to keys for > dictionaries/hashes" landmine. This isn't a landmine; this is a _good_ thing. Python is strongly typed. > Is there a good wa

Re: dictionary/hash and '1' versus 1

2008-01-03 Thread Steven D'Aprano
On Thu, 03 Jan 2008 16:56:00 -0600, Reedick, Andrew wrote: > The problem occurred because a method used to generate keys was > returning a string instead of a number without an explicit conversion > taking place. And since I was using hash.get(i, default_value) to avoid > having to pair every key

Re: dictionary/hash and '1' versus 1

2008-01-03 Thread Stephen Hansen
> As a Perl monkey in the process of learning Python, I just stepped on > the "'1' (string) is not the same as 1 (integer) in regards to keys for > dictionaries/hashes" landmine. Is there a good way to ensure that > numbers represented as strings or ints do not get mixed up as keys? > Well one im

Re: dictionary/hash and '1' versus 1

2008-01-03 Thread John Machin
On Jan 4, 9:56 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > As a Perl monkey in the process of learning Python, I just stepped on > the "'1' (string) is not the same as 1 (integer) in regards to keys for > dictionaries/hashes" landmine. Congratulations. You have just stepped off the "'1' (st