how to refactor nested for loop into smaller for loop assume each of them independent?

Steve D'Aprano steve+python at pearwood.info
Sat Oct 8 07:29:04 EDT 2016


On Sat, 8 Oct 2016 09:12 pm, BartC wrote:

> The OP's code however is a good demonstration of how crazy Python's
> original for-range loop was: you need to construct a list of N elements
> just to be able to count to N. How many years was it until xrange was
> introduced?

Python 1.4 (that's 1996) had xrange, but I don't know when it was added.

https://docs.python.org/release/1.4/lib/node26.html#SECTION00330000000000000000


The oldest version I have access to is the *extremely* primitive 0.9. Not
surprisingly, it doesn't have xrange -- but it lacks a lot of things,
including globals(), map(), named exceptions, "" strings ('' is okay),
exponentiation, and more.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list