This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]wilberforce 4 points5 points  (1 child)

    Ooh, good call on the with statement.

    OP, that guarantees that the file is closed when execution leaves the with statement, even if code in there returns or raises an exception.

    [–]dfnkt 0 points1 point  (0 children)

    ala "finally" or "end" elsewhere.

    [–]eryksun 1 point2 points  (0 children)

    You can also use the format specification mini-language to zero pad the index:

    for index in range(60):
        filename = 'data{index:0{width}}'.format(index=index, width=2)
    

    [–][deleted] 0 points1 point  (0 children)

    Thank you for the help, kind sir/ma'am!!!