Open (txt) editor and get its content

Rhodri James rhodri at kynesim.co.uk
Thu Apr 19 07:46:25 EDT 2018


On 19/04/18 08:39, zljubisic at gmail.com wrote:
> Hi,
> 
> I have a script that should accept sql query as a parameter and change it in a way. For now I have a file in which I have put sql query and than python script opens it and do everything else.
> 
> Is it possible to run python script that will open editor and let me paste sql query in the editor, and than after closing editor, get editor's content in python script?

You already have the query in a file, so you can just use 
subprocess.run() to start your favourite editor and wait until it exits, 
then *check the return code* (if you don't, you will wish you had) and 
read the file back.

> Is there any other option for getting interactive multi line input from user.

input() and patience :-)

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list