How to run script from interpreter?

Mark H Harris harrismh777 at gmail.com
Thu May 29 16:26:37 EDT 2014


On 5/28/14 10:22 PM, Steven D'Aprano wrote:
>> If you want to use python as a shell-glue you can try using system.
>>
>>   >>> from os import system
>>   >>> def <function_name>([parms])
>>   >>> .... blah blah
>>   >>> .... rc = system("<your_script_name")
>
>
> os.system is cool for quick and dirty calls to an external command. But
> for serious work, the subprocess module is better.
>

    ... yup, particularly for non trivial network related stuff.


Neither here nor there, but I just learned the ";" character command 
today for the Julia REPL, and got to thinking that python should have a 
similar way for the REPL to drop into "shell" mode for system commands.

So, I might code a clear screen in python:

def cls()
    rc = system("clear")


or in Julia

function cls()
    run(`clear`)
end

...  but on Julia we can also do this:

; clear

On the Julia REPL the ";" character drops the julia prompt into shell. I 
think the IDLE REPL should have a system shell mode. What say you?

marcus




More information about the Python-list mailing list