Why does one work, but not the other?

Erik Max Francis max at alcyone.com
Thu Jun 17 22:08:16 EDT 2004


j_mckitrick wrote:

> but when I try:
> 
>         self.liststore = [[item] for item in data]
> 
> instead of:
> 
>        for item in data:
>             self.liststore.append([item])
> 
> I get an empty list!  What gives??

You're probably doing something else wrong; this fragment works fine:

>>> data = [1, 2, 3, 4]
>>> [[item] for item in data]
[[1], [2], [3], [4]]

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Ferocious, aren't I?
    -- Lt. Vincent Hanna



More information about the Python-list mailing list