On 2/1/2019 9:24 AM, Ken Hilton wrote:
Hi,

As a workaround/alternative, you can just do

     >>> import os
     >>> os.system('dir')

For repeated use within and between sessions, put 'from os import system as oss' in a startup file. Then one only needs "oss('dir')". Note that 'dir' only works on Windows; the unix equivalent is 'ls'.

However this will not work in a gui IDE without special handling in the IDE. This docstring for os.system says "Execute the command in a subshell." (It should say "Execute the command in a subshell and return the exitcode.") I presume that this docstring assumes that one is running python is a system shell and that the subshell is a 'sub' of the system shell.

Anyway, the subshell expects the output, in this case, a directory listing, to go to an attached system console. If one enters the above in IDLE's shell, the output does not appear in IDLE's shell. If one started IDLE in a terminal with 'python(3) -m idlelib', it goes to that terminal. Otherwise, it goes to a subshell which immediately closes and which may or may not flash on the screen.

--
Terry Jan Reedy


_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to