"per9000" <[EMAIL PROTECTED]> writes: > appendix = '.txt' # or '.csv' or whatever > > # some code > > c += 1 > filetitle = 'result_' + zeropadding(c) + str(c) > myfile = open(filetitle+appendix,'w')
Resist the urge to construct strings by concatenation, when Python's built-in string formatting operations will do the job more elegantly. >>> filesuffix = ".txt" >>> count = 123 >>> filename = "result_%05d%s" % (count, filesuffix) >>> print filename result_00123.txt -- \ "When you go in for a job interview, I think a good thing to | `\ ask is if they ever press charges." -- Jack Handey | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list