This may be a confusing question. After writing a text file I would like to execute a command in Python which can open the text file created in a text viewing application, such as the default text editor supplied with Mac OSX. I was wondering how this could be done within the script...? I'd like to specify which program to open it in because the extension won't be automatically recognised.
Asked
Active
Viewed 55 times
0
-
You probably want to use subprocess http://stackoverflow.com/a/204049/5616110 – iScrE4m Jul 14 '16 at 19:26
-
[This](http://stackoverflow.com/a/21857203/6469907) is another example of using a [subprocess](https://docs.python.org/3/library/subprocess.html). Good luck! – pat Jul 14 '16 at 19:49
-
1@pat I've tried using the subprocess routine/module, but I get this following error: `subprocess.call(['open', '-a', 'TextEdit', table_ssp_M33_SWIFT.cat]) NameError: name 'table_ssp_M33_SWIFT' is not defined` – Jul 14 '16 at 19:55
-
2Put the error'd bit in quotes. – Athena Jul 14 '16 at 20:02
-
Did that just before you commented, works like a charm! – Jul 14 '16 at 20:03