Re: [Tutor] More type() puzzlement

2007-10-28 Thread Dick Moores
At 01:53 AM 10/28/2007, you wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > > So you're saying that it's to be expected that the analogy, "int is > > to long as int is to float" will hold. But why should it be expected > > to hold? float and long are completely different animals, no? > >No, th

Re: [Tutor] More type() puzzlement

2007-10-28 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > So you're saying that it's to be expected that the analogy, "int is > to long as int is to float" will hold. But why should it be expected > to hold? float and long are completely different animals, no? No, they are all types of numbers. The general rule

Re: [Tutor] More type() puzzlement

2007-10-27 Thread Dick Moores
At 04:06 PM 10/27/2007, Alan Gauld wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > >> Hence if type(n) is already long it does not have to get converted > >> to int to accommodate something small. > > > > And that's not a bug? > >No its expected behaviour. >If you start with a float and add an

Re: [Tutor] More type() puzzlement

2007-10-27 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote >> Hence if type(n) is already long it does not have to get converted >> to int to accommodate something small. > > And that's not a bug? No its expected behaviour. If you start with a float and add an integer the result is a float. Why should long act any

Re: [Tutor] More type() puzzlement

2007-10-27 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > n = 100 You start with n as a long. > print type(n) > while True: > if type(n) == long: > n -= 100 A long minus an int gives a long: >>> n = long(42) >>> n 42L >>> n - 3 39L So n never changes into an int even though it is wit

Re: [Tutor] More type() puzzlement

2007-10-27 Thread Dick Moores
At 10:27 AM 10/27/2007, Jeff Younker wrote: >On Oct 27, 2007, at 12:52 PM, Dick Moores wrote: >>At 08:39 AM 10/27/2007, Aditya Lal wrote: >>> Hence if type(n) is already long it does not have to get converted >>>to int to accommodate something small. >> >>And that's not a bug? > >There is no need

Re: [Tutor] More type() puzzlement

2007-10-27 Thread Jeff Younker
On Oct 27, 2007, at 12:52 PM, Dick Moores wrote: > At 08:39 AM 10/27/2007, Aditya Lal wrote: >> Hence if type(n) is already long it does not have to get converted >> to int to accommodate something small. > > And that's not a bug? There is no need for a type change to represent zero, so, no, that

Re: [Tutor] More type() puzzlement

2007-10-27 Thread Dick Moores
At 08:39 AM 10/27/2007, Aditya Lal wrote: >I would expect that a type change will happen if there is a need. Hey, I HAD a need! OK, a made-up one. > Hence if type(n) is already long it does not have to get converted > to int to accommodate something small. And that's not a bug? >I changed you

Re: [Tutor] More type() puzzlement

2007-10-27 Thread Aditya Lal
On 10/27/07, Dick Moores <[EMAIL PROTECTED]> wrote: > > Win XP, Python 2.5.1 > > > #!/usr/bin/env python > #coding=utf-8 > > n = 100 # 10 billion > print "type of 10 billion is", type(n) > n = 10 # 1 billion > print "type of 1 billion is", type(n) > > raw_in

[Tutor] More type() puzzlement

2007-10-27 Thread Dick Moores
Win XP, Python 2.5.1 #!/usr/bin/env python #coding=utf-8 n = 100 # 10 billion print "type of 10 billion is", type(n) n = 10 # 1 billion print "type of 1 billion is", type(n) raw_input("press enter to continue") n = 100 print type(n) while True: