Top and Bottom Values [PEP: 326]

Tim Chase python.list at tim.thechases.com
Wed Sep 27 15:05:50 EDT 2006


>> To begin with this already fails:
>>
>>>>> for i in xrange(Top):
>> ...   print i
> 
>     	What do you expect this to do?  Loop forever?

Perhaps the infinite loop should take half as long as

 >>> for i in xrange(Bottom, Top): print i

Though then the values when the loop first starts are kinda 
ambiguous... :)

Given the limits of xrange:

 >>> for i in 
xrange(10000000000000000000000000,10000000000000000000000009):
...	print i

Traceback (most recent call last):
   File "<stdin>", line 1, in ?
OverflowError: long int too large to convert to int

I suspect one would have an overflow condition to help break you 
out of the loop...

 >>> try:
...	for i in range(Top):
...		print i
... except OverflowError:
...	print 'done!'



...and then you time your instruction cycles and your disk reads 
so they fall under the read-head at just the right time... [*]

-tkc



[*] http://www.catb.org/jargon/html/story-of-mel.html



More information about the Python-list mailing list