Re: a print bug?

2006-07-27 Thread Summercoolness
Steve Holden wrote: > You obviously haven't yet passed your floating-point number proficiency > test yet. Please restrict yourself to integers until you understand the > difficulties that inaccuracies in floating-point can create ;-) hm, actually, i understand the limitation of floating point. but

Re: a print bug?

2006-07-27 Thread Summercoolness
Duncan Booth wrote: > But you wouldn't complain about this would you? > > >>> print "%10.4f" % 1.23445 > 1.2345 > >>> print "%10.3f" % 1.23445 > 1.234 > > A value which is slightly than 1.2345 prints to 4 decimal places as 1.2345 > and to 3 decimal places as 1.234. > > That's all that hap

Re: a print bug?

2006-07-26 Thread Summercoolness
[EMAIL PROTECTED] wrote: > how about the discrepancy between > > >>> print 1.2345 > > 1.2345 > > >>> print "%10.3f" % 1.2345# seems like a bug > > 1.234 > > the first one, print knows enough to recognize and print it as 1.2345. > however, in the second line, when it is round off, it doesn

Re: a print bug?

2006-07-26 Thread Summercoolness
Sybren Stuvel wrote: > It has nothing to do with the print command, and everything with > floating point precision. See http://docs.python.org/tut/node16.html how about the discrepancy between >>> print 1.2345 1.2345 >>> print "%10.3f" % 1.2345# seems like a bug 1.234 the first one

a print bug?

2006-07-26 Thread Summercoolness
it seems that the behavior of "print" is that it will round off properly for any floating point imperfection, such as shown in the first two samples. The third sample seems to be a bug? It doesn't know how to handle the floating imperfection in this case. >>> 1.2345 1.2344 >>> print

Re: range() is not the best way to check range?

2006-07-18 Thread Summercoolness
[EMAIL PROTECTED] wrote: > it seems that range() can be really slow: > > if i in range (0, 1): My original use was like this: if i in range (iStart, iEnd): listData.append(a) in which iStart is 1000 and iEnd is 1008 so in that case, the program ran fine... but later on, i

range() is not the best way to check range?

2006-07-17 Thread Summercoolness
it seems that range() can be really slow: the following program will run, and the last line shows how long it ran for: import time startTime = time.time() a = 1.0 for i in range(0, 3): if i in range (0, 1): a += 1 if not i % 1000: print i print a, " ", round(time.time

array of array of float

2006-07-09 Thread Summercoolness
i used C too much and haven't used Python for a while... like in C, if we want an array of array of float, we use float a[200][500]; now in Python, seems like we have to do something like a = [ [ ] ] * 200 and then just use a[1].append(12.34) etc but it turns out that all 200 elements poin

Re: looks like in PIL, resize() will give high quality thumbnails than thumbnail()

2006-07-01 Thread Summercoolness
[EMAIL PROTECTED] wrote: > In PIL, since thumbnail() first makes a draft copy of the image, and > then resize it, so thumbnail() can run a lot faster than resize() > because draft() seems a lot faster when resizing from very big images > to small images... (such as the original image is 3000 x 20

looks like in PIL, resize() will give high quality thumbnails than thumbnail()

2006-07-01 Thread Summercoolness
In PIL, since thumbnail() first makes a draft copy of the image, and then resize it, so thumbnail() can run a lot faster than resize() because draft() seems a lot faster when resizing from very big images to small images... (such as the original image is 3000 x 2000, and it can make a draft really