if STREAM.isatty():

Eryk Sun eryksun at gmail.com
Fri Aug 30 15:38:27 EDT 2019


On 8/30/19, Chris Angelico <rosuav at gmail.com> wrote:
> On Sat, Aug 31, 2019 at 2:26 AM Michael Torrie <torriem at gmail.com> wrote:
>> On Fri, Aug 30, 2019, 05:02 Hongyi Zhao <hongyi.zhao at gmail.com wrote:
>>
>>> Because without using sleep, the stuff on screen will display very
>>> shortly and then disappear.  Is this not your testing result?
>>
>> No it is not. What kind of terminal are you using?
>
> Probably a Windows computer and just double-clicking on the program to
> make it do stuff.
>
> Recommendation: If that's the case, get an actual terminal. Learn to use
> it.

Or simply run python.exe from another console process that keeps the
console alive (it's reference counted), which is typically cmd.exe or
powershell.exe. Or have the script spawn a process that keeps the
console alive (e.g. subprocess.Popen('cmd')). Or configure .py files
to use the py.exe launcher and change the shebang to `#!python3 -i`
when testing a script, which runs the REPL after the script
terminates.



More information about the Python-list mailing list