multiple discontinued ranges

Emile van Sebille emile at
Wed Nov 10 21:35:51 CET 2010

On 11/10/2010 9:34 AM xoff said...
> On 10 nov, 18:15, Paul Rubin<no.em... at nospam.invalid>  wrote:
>> potentially lots of storage (you should use xrange instead).  On the
>> other hand you could just concatenate the lists with +, but I wouldn't
>> advise that.
> I am curious, why wouldn't you advise something like this:
> for i in chain(range(3,7) + range(17,23)):

I'd assume because concatenation is generally considered expensive.

If you were to do it, you'd likely drop the chain and write:

for i in range(3,7) + range(17,23):


More information about the Python-list mailing list