that is exactly what i am looking for, but how would i add this to my filename??? should i use this:
output_file = open(os.path.join(self.Save_Session.GetValue(), time.strftime('%Y%m%d%H%M')), 'w') the self.Save_Session.GetValue() is generated by a dirdialog On Tue, 15 Mar 2005 09:41:35 -0600, C Smith <[EMAIL PROTECTED]> wrote: > > On Tuesday, Mar 15, 2005, at 05:01 America/Chicago, > [EMAIL PROTECTED] wrote: > > > how am i going to change the filename automaticaly? > > for example: > > #every 5 minutes, i am going to create a file based on the > > data above > > for i in range(100) > > output_file = file('c:/output' +.join(i) +'.txt', 'w') > > #guess this won't work > > output_file.writelines(lines) > > output_file.close() > > > > When faced with this problem, one of the tings that I liked to do was > use a date stamp for the files. The time module has a function called > strftime which allows you to use a template to create a string from the > current time. (See the documentation of python module 'time' for more > details.) e.g. > > ### > >>> import time > >>> time.strftime('%Y%m%d%H%M') > '200503150934' > ### > > This string can be added to your 'c:/output' rather than a generic > number like i. Just to be safe you might want to check that the file > doesn't already exist. The nice thing is that there should be few files > that have this number added to them so the loop to get a valid name is > going to succeed quickly. > > /c > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor