How to create a tuple quickly with list comprehension?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Wed Jun 13 06:37:02 EDT 2007


In <5d9ngkF32j8imU1 at mid.uni-berlin.de>, Diez B. Roggisch wrote:

> No need to create the intermediate list, a generator expression works just
> fine:
> 
> a = tuple(i for i in range(10))

But `range()` creates the intermediate list anyway.  ;-)

a = tuple(xrange(10))

Ciao,

	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list