multiple discontinued ranges

Nobody nobody at nowhere.com
Wed Nov 10 15:04:15 EST 2010


On Wed, 10 Nov 2010 09:34:14 -0800, xoff wrote:

> I am curious, why wouldn't you advise something like this:
> for i in chain(range(3,7) + range(17,23)):

Because it constructs all three lists (both of the individual ranges and
their concatenation) in memory. For a trivial example, that isn't a
problem; for a real application, it could be.




More information about the Python-list mailing list