Python 2.7 range Function provokes a Memory Error

Stephen Tucker stephen_tucker at sil.org
Thu Mar 2 06:25:49 EST 2023


Hi,

The range function in Python 2.7 (and yes, I know that it is now
superseded), provokes a Memory Error when asked to deiliver a very long
list of values.

I assume that this is because the function produces a list which it then
iterates through.

1. Does the  range  function in Python 3.x behave the same way?

2. Is there any equivalent way that behaves more like a  for loop (that is,
without producing a list)?

To get round the problem I have written my own software that is used in a
for  loop.

Stephen Tucker.


More information about the Python-list mailing list