Thanks for the input folks. Sadly, Tim's suggestion yields the same results as I was getting previously. My second program very graciously tells me that the file I'm trying to open doesn't exist. Like the code snippet I posted, the timer.sleep(x) line just waits the 'x' seconds until opening 'mytextfile.xyz", instead of opening it, and then waiting 'x' seconds to delete the file. Sorry about naming the path to my file so "poorly"!! I'm a little more careful in my programs! I'm a newbie and I was more concerned about an understandable question!
As a newbie, Alan, I was kinda scared you'd say that "threads" were the answer here! (It sounds like someone is going to get sucked into a worm hole or something...) Looks like the next class in my Python education is going to be "Threads 101"... Thanks for all the input, I might even be learning something! Warmest regards, Adrian On Mon, Oct 6, 2008 at 1:31 PM, Alan Gauld <[EMAIL PROTECTED]>wrote: > > "Adrian Greyling" <[EMAIL PROTECTED]> wrote > > that creates my "problem"... What I'd like to do, is create a plain text >> file, use the associated program to open said textfile, (using >> os.startfile) >> and after the associated program has what it needs to open the file and >> then >> of course, has the current focus, I'd like to delete the text file >> > > Thats potentially going to cause the associated program to crash > but assuming you know what you are doing there... > > What happens with the code snippet below, is that it doesn't start >> the second program until the function is finished. >> > > Correct, that's what you asked it to do :-) > > time.sleep() in between the os.startfile() and os.remove(), but it just >> delays opening 'mytextfile.xyz' and actually deletes the file before my >> second program can open it up. >> > > Really? That shouldn't happen! > > path = "c:\MyFolder\mytextfile.xyz" >> > > You probably want to either use forward slashes or put > an r in front of the quotes, otherwise Python will treat > the \ as an escape character... > > #bunch of stuff here to create 'mytextfile.xyz" >> os.startfile(path) >> os.remove(path) >> > > If you want the remove to run in parallel with the startfile > you probably need to use threads to start the application > in one thread and then pause and then delete the file in > the other thread. > > Alan > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor