On Thu, 10 Jan 2008 22:36:56 -0500 Marty <[EMAIL PROTECTED]> wrote: > I recently faced a similar issue doing something like this: > > data_out = [] > for i in range(len(data_in)): > data_out.append([])
More succinctly: data_out = [] for _ in data_in: data_out.append([]) Or, as has already been pointed out: data_out = [[] for _ in data_in] > 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? But I'm curious - what's the difference between the "foreach" you have in mind and the standard python "for"? <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list