> On 16 Oct 2020, at 14:44, Rob Cliffe via Python-ideas 
> <python-ideas@python.org> wrote:
> 
> 
> 
> On 16/10/2020 13:55, Chris Angelico wrote:
>> 
>>> I do precisely that in many of my programs for e.g. single-line progress
>>> displays.
>>> But for multi-line output I don't know of any way to move the cursor
>>> back up.
>>> I work in Windows 10.
>> Try \x1b[A to move up a line, should work.

I find that you have to do this to turn on ANSI processing in CMD.EXE on Window 
10
and I assume earlier Windwows as wel:

import ctypes
kernel32 = ctypes.windll.kernel32
# turn on the console ANSI colour handling
kernel32.SetConsoleMode( kernel32.GetStdHandle( -11 ), 7 )

Now you can use escape sequences:

print('\x1b[31m Hello in red \x1b[m')

Given the need to call WIN32 APIs to get this working making this part
of stdlib would help a lot.

Barry


>> 
>> ChrisA
> Got it working!  The answer is
>      \x1b[1A
> Thanks for the pointer!
> Rob Cliffe
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/B3HVTOIQBA6YGCK4TJRLQW4FTBF2IXAQ/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ZJVCAOCUUFCVWVPJQEUROUX5U4TUF2K4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to