Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17825 > unrolled thread
| Started by | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| First post | 2011-12-23 16:01 -0500 |
| Last post | 2011-12-23 16:01 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Idiom for shelling out to $EDITOR/$PAGER? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-12-23 16:01 -0500
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| Date | 2011-12-23 16:01 -0500 |
| Subject | Re: Idiom for shelling out to $EDITOR/$PAGER? |
| Message-ID | <mailman.4039.1324674121.27778.python-list@python.org> |
> Windows may hate you for this with its locking behaviour for open files, > but it will work for UNIX. Windows won't let you open the file while NamedTemporaryFile has a hold on it, yeah. Your point is legitimate anyway. Even so, there's still the race conditions for "what if the tempfile is moved before the editor can get to it" and "what if the tempfile is moved after the editor can get to it but before I can open it again". -- Devin On Fri, Dec 23, 2011 at 2:47 PM, Cameron Simpson <cs@zip.com.au> wrote: > On 23Dec2011 02:21, Devin Jeanpierre <jeanpierreda@gmail.com> wrote: > | > Anyway, look it up; it has an autodelete mode etc. > | > | The autodelete isn't useful in this context. The file needs to be > | closed and then reopened again; with the autodelete option, the > | closing would delete the file, preventing it from being opened by the > | text editor or reopened to check contents. > | > | (As far as I know, the race condition inherent in this is unavoidable. > | At least on windows, but I couldn't figure out any other way on Linux > | either.) > > You can fire off the editor from inside the with statement. > Write contents, flush, edit, open T.name for read, read, close, exit > with statement. > > Windows may hate you for this with its locking behaviour for open files, > but it will work for UNIX. > > Cheers, > -- > Cameron Simpson <cs@zip.com.au> DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > The elliptical cam has gradually slid up the beam shaft and caught on the > flange rebate dislodging the gripley, with disastrous results. > - Death, 'Reaper Man' (Pratchett)
Back to top | Article view | comp.lang.python
csiph-web