Is it possible to use arcpy to open up an editor (like Notepad) to show a simple text file? I'd like to do this in a tool that generates text which is supposed to be copied and pasted into another text file.

If there is a built-in method of showing text without all the other tool output, I'd prefer that.

Having the text already selected would be a bonus.

  • Can you use other modules such as subprocess? If you are just copy and pasting, why not just do that in your script as well? Jun 29 '16 at 8:43
  • Well if they are standard modules, I can use them. Copy/paste into the target file is something that should be done by a human, though.
    – Christoph
    Jun 29 '16 at 8:46
  • Python has several methods for creating, reading, and writing text files. Why bother opening the text in a text editor only to copy and paste when you can write directly to the receiving text file with Python?
    – GBG
    Jul 8 '16 at 17:19
  • @gbg inserting into the file should be done by a human who can tell where and how the output must be inserted.
    – Christoph
    Jul 8 '16 at 19:38
  • OK,- I found this link showing how to write the text string to the Windows clipboard. stackoverflow.com/questions/579687/…
    – GBG
    Jul 11 '16 at 15:09

If you have python >= 2.4 you could include the subprocess module in your script and call that


import subprocess
path = r'path/to/your/file.txt'
subprocess.Popen(['notepad.exe', path])

or the os module will open the file with its default application


import os
  • startfile is convenient because it uses the standard application, but unfortunately it doesn't wait. I'd like to wait for the editor to be closed, though, to remove the temporary file I need to create to show the copy/paste output. subprocess.call waits, but I need to know the application name then
    – Christoph
    Jun 29 '16 at 9:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.