How to determine if IO redirection is occurring with the output from a Python program?

Dan Stromberg drsalists at gmail.com
Wed Apr 18 17:06:13 EDT 2012


On Tue, Apr 17, 2012 at 5:52 PM, Chris Angelico <rosuav at gmail.com> wrote:

>
> isatty() is supported on Windows (the underlying C API is different,
> but the beauty of a high-level language is that you no longer need to
> care), but the standard Windows console doesn't support ANSI
> sequences. I think there is a way to enable them, but I don't recall
> it off hand. However, if you can pipe your output through a socket
> connection, a MUD client can be your console. There are plenty around;
> RosMud [1] is a quite light-weight one that I wrote some years ago,
> and use constantly. Going for a MUD connection may feel a little
> weird, but it's pretty easy, and it gives you instant cross-platform
> networking capabilities.
>

Last I heard, you could set up ANSI escape sequences using a line in
config.sys.   This was back in the MS-DOS/PC-DOS days with command.com.
I've not tried it on cmd.exe or powershell.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120418/e170bc28/attachment-0001.html>


More information about the Python-list mailing list