> On Behalf Of Marty
> I recently faced a similar issue doing something like this:
> 
>      data_out = []
>      for i in range(len(data_in)):
>       data_out.append([])
> 
> This caused me to wonder why Python does not have a "foreach" 
> statement (and also why has it not come up in this thread)?  
> I realize the topic has probably been beaten to death in 
> earlier thread(s), but does anyone have the short answer?

data_out = [[] for item in data_in]

Regards,
Ryan Ginstrom

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to