7stud <[EMAIL PROTECTED]> writes:
> for i in range(num):
>     dir_name = "new_dir%s" % i  #same result as "new_dir" + str(i)
>     os.mkdir(dir_name)  #creates dirs in current directory

I find it's useful to keep all the filenames the same length and
put leading zeros in the directory numbers, so that sorting their
names lexicographically puts them in numerical order.  Untested:

    fmt = "new_dir%0%d" % len(str(num))
    for i in xrange(num):
        os.mkdir(fmt % i)

Or if num is unknown but you have some upper bound like 1000,
you could just use %05d or something like that.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to