On Sun, May 22, 2011 at 8:48 PM, Shunichi Wakabayashi
wrote:
> One idea is using contextlib.nested(),
>
> from contextlib import nested
>
> with nested(*[open('list_%d.txt' % i, 'w') for i in range(LIST_LEN)]) as
> fobjlist:
> for i in range(1000):
> fobjlist[random.randrange(LIST_LEN)].write
To write onto multiple files on the same time (a number of files are variable),
I'd like to code as follows, for example, IF I can do,
LIST_LEN = 4
with [ open('list_%d.txt' % i, 'w') for i in range(LIST_LEN) ] as fobjlist:
for i in range(1000):
fobjlist[random.randrange(LIST_LEN)].write(str