"Wayne Watson" <[EMAIL PROTECTED]> wrote
I need to use something like sys.exit().

sys.exit won't change the file permissions etc. It simply sets the exit status of the program.

I suspect the problem is that you still have IDLE running.
Have you tried testing the program outside IDLE? You might find it works OK there.

Also have you checked your file permissions? You may need to change the default settings using the os module.

However, I'm in development mode right now with IDLE, and there's a small penalty for using it with IDLE.

The "penalty" is actually a benefit since having to restart IDLE and reload your working files each time you run your code is much less convenient than clicking a dialog button! :-)

Although I user might try to rename 500 files at a single shot.

I assume you are intending enhancing the program to accept multiple ufilenames?

     def modify_txt_file(old_fname, new_event_date):
         old_prefix = old_fname[0:19]

You might want to use os.basename() here as a more reliable way of extracting the extension.

         input_file=open(old_fname,'r')
         output_file=open(old_prefix+'.tmp','w')

         print "modified txt file with event info"
         # now copy tmp back to ...

And you might want to use os.remove() and os.rename() to do the final copy of the tmp file back to the original.

Just some thoughts

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to