Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72929

Re: os.startfile hanging onto the launched app, or my IDE?

Date 2014-06-07 21:24 +0100
From Tim Golden <mail@timgolden.me.uk>
Subject Re: os.startfile hanging onto the launched app, or my IDE?
References <c9c00856-4a8c-4a49-95b7-62d83aa7f2bf@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.10860.1402172663.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 06/06/2014 21:34, Josh English wrote:
> I have been using os.startfile(filepath) to launch files I've created
> in Python, mostly Excel spreadsheets, text files, or PDFs.
>
> When I run my script from my IDE, the file opens as I expect. But if
> I go back to my script and re-run it, the external program (either
> Excel, Notepad, or Acrobat Reader) closes all windows and restarts
> the program. This can, unfortunately, close other files I am working
> on and thus I lose all my changes to those files.
>
> This is happening on Windows 7.
>
> I am not sure if it is Python (2.7.5) or my IDE (PyScripter 2.5.3).
>
> It seems like Python or the IDE is keeping track of things created by
> the os.startfile call, but the docs imply this doesn't happen.
>
> Is this a quirk of os.startfile? Is there a cleaner way to get
> Windows to open files without tying back to my program?

I'm not 100% sure what your scenario is, but you can certainly help 
yourself and us by running the same test on the raw interpreter and then 
under PyScripter to determine if the behaviour is to do with IDLE or 
with Python itself.

My half-guess is that PyScripter starts a new process to run your code, 
possibly killing any pre-existing process first. That's if I've 
understood the situation you're describing.

Could you come back with a little more detail? Specifically: whether 
what you're seeing happens only from within PyScripter, or only not from 
within PyScripter, or something else?

TJG

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

os.startfile hanging onto the launched app, or my IDE? Josh English <Joshua.R.English@gmail.com> - 2014-06-06 13:34 -0700
  Re: os.startfile hanging onto the launched app, or my IDE? Tim Golden <mail@timgolden.me.uk> - 2014-06-07 21:24 +0100
    Re: os.startfile hanging onto the launched app, or my IDE? Josh English <Joshua.R.English@gmail.com> - 2014-06-09 15:21 -0700
      Re: os.startfile hanging onto the launched app, or my IDE? Ethan Furman <ethan@stoneleaf.us> - 2014-06-09 15:31 -0700
      Re: os.startfile hanging onto the launched app, or my IDE? Tim Golden <mail@timgolden.me.uk> - 2014-06-10 05:46 +0100
      Re: os.startfile hanging onto the launched app, or my IDE? Ethan Furman <ethan@stoneleaf.us> - 2014-06-10 13:45 -0700
  Re: os.startfile hanging onto the launched app, or my IDE? Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-08 11:56 -0600

csiph-web