Creating 50K text files in python

Marco Mariani marco at sferacarta.com
Wed Mar 18 15:15:20 CET 2009


venutaurus539 at gmail.com wrote:

>>>     for k in range (1,1001):
>>        ...
>>>         k = k+1
>> Man, you have a trouble with loops, all over.
> 
> But the situation demands it.:-(

No. I mean, the for loops are wrong.

Compare with the following and see why

> import os
> 
> base = '/tmp/foo'
> 
> for outer in xrange(1,6):
>     for inner in xrange(1,11):
>         d = os.path.join(base, str(outer), str(inner))
>         os.makedirs(d)
>         for fnum in xrange(1,1001):
>             file(os.path.join(d,str(fnum)), 'w').close()



More information about the Python-list mailing list