On Sat, Apr 27, 2013 at 1:22 AM, <tunacu...@gmail.com> wrote: >> I've checked out what fileinput.input() is doing here (ought to have >> >> done that earlier, sorry!) and I now understand this block of code >> >> more. You're replacing that word _in the file, on disk_, and then >> >> making the inverse replacement. This strikes me as dangerous; if >> >> anything happens to your process in the middle, the file will be >> >> damaged on disk. I would STRONGLY recommend rewriting this to use some >> >> other file - for instance, a temporary file. I haven't looked into the >> >> details, as I haven't actually done this lately in Python, but you >> >> should be able to use tempfile.NamedTemporaryFile(delete=False) [1], >> >> write to it, make it executable, run it, and unlink it. That way, >> >> you're creating a temporary file to run, not running the original. >> >> This is semantically different from your code, but I think it'd be a >> >> lot safer. > > Thank you, Chris! I got it working and am going to take your advice on the > tempfile idea. I actually ran into the problem you were referring to, and > kept the .ahk files backed up elsewhere for when this situation arose. I > appreciate the help!
Awesome! Hey, you want to know an easy way to show your appreciation for the people who answer your questions? It's really simple: Step 1: Don't use Google Groups to post. Step 2: Profit! Have a look at the quoted text in your responses. See how it's double-spaced and really obnoxious? That's not your fault, it's because Google Groups is buggy. There are plenty of other ways to read and post; I personally have subscribed to the mailing list and read it using Gmail, and there are a variety of other ways too. If you _must_ use Google Groups, check out this page for some recommendations on how to not offend people. http://wiki.python.org/moin/GoogleGroupsPython There are a number of non-G-rated terms going around that fairly accurately describe what Google Groups posts look like, but since I prefer milder language, I'll just repeat the word "obnoxious", as it carries all the meaning I need. ChrisA -- http://mail.python.org/mailman/listinfo/python-list