Editing text with an external editor in Python

Chris Angelico rosuav at gmail.com
Tue Sep 2 00:30:01 CEST 2014

On Tue, Sep 2, 2014 at 4:23 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Chris Angelico wrote:
>> C:\>Python34\python 123123123.py
>> cygwin warning:
>>   MS-DOS style path detected: C:\DOCUME~1\M\LOCALS~1\Temp\tmp94rcwd57
>>   Preferred POSIX equivalent is: /DOCUME~1/M/LOCALS~1/Temp/tmp94rcwd57
> That's arguably a Python bug. Under Cygwin, it should use POSIX paths rather
> than Windows paths.

Except that I wasn't; I ran Python 3.4 that was installed via the .msi
package, and from that Python ran nano that was presumably compiled
for Cygwin.

>> Windows doesn't have a nice $EDITOR environment variable to call on,
> Why not? It's your environment, you can create any environment variable you
> like, even under Windows, right?

Sure, but what I mean is, there's a general convention on Unix that
setting EDITOR will do that. You don't get to take advantage of
expectations that easily on Windows.

> But fundamentally, the de facto "standard editor" on Windows is Notepad.

Sadly so. Which is why I tried it...

>> You'll also have to cope with some other possibilities. What happens
>> if someone tries Notepad? (Don't try this at home. We are experts and
>> are testing on a closed track. Do not use Notepad unless you, too,
>> have thirty years of special effects experience.) Turns out it doesn't
>> like working with a file that another process has open.
> Ah, I feared that would be the case. I'll have to think about a way around
> that. It won't be as neat, or as secure, but it should be doable.

... and yeah. That's the problem.


More information about the Python-list mailing list