multiple discontinued ranges
Emile van Sebille
emile at fenx.com
Wed Nov 10 15:35:51 EST 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):
Emile
More information about the Python-list
mailing list