How to create a tuple quickly with list comprehension?

Dustan DustanGroups at gmail.com
Wed Jun 13 07:34:18 EDT 2007


On Jun 13, 5:37 am, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> In <5d9ngkF32j8i... 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.  ;-)

I imagine that's special case.




More information about the Python-list mailing list