How do I initialize a list please?

Christian Tismer tismer at tismer.com
Tue Dec 31 20:35:59 EST 2002


Mike C. Fletcher wrote:
> Well, although it's less compact, I kinda like this approach for 
> list-initialisation w/ list comps because it uses the same paradigm 
> everywhere (instead of mults in one place and comps in another). 
> Downside is that it's more verbose, and may freak some of the peanut 
> gallery out ;) .  When you come to change the comprehension to do 
> something more (such as include i or j in the result), it's just a 
> matter of changing the output fragment...
> 
> newstructure = [
>    [ 1.0  for i in range(10) ]
>    for j in range(10)
> ]

Absolutely, Mike, I agree.

I just could not extend to this, since an obvious
one-liner must live in a short message, or it
will miss its desired effect.
I was waiting for this, thanks for chiming in.

the-opposite-would-require-a-deep-multiply-
   -operator-and-happy-new-year-ly y'rs - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/







More information about the Python-list mailing list