I found strange thing while studying through idle

Paul Moore p.f.moore at gmail.com
Fri Mar 9 13:10:57 EST 2018


On 9 March 2018 at 17:46, Rob Gaddi <rgaddi at highlandtechnology.invalid> wrote:
> On 03/08/2018 07:57 PM, Steven D'Aprano wrote:
>>
>> [snip]
>>
>> But it is possible that due to differences between platforms, the
>> OP's version of IDLE doesn't display a carriage return as \r but
>> rather as an invisible zero-width space.
>>
>
> Just to derail this conversation a bit, does anyone have a use case in the
> modern (Py3) age for '\r'?  I use b'\r' fairly regularly when talking to
> serial port devices.  But the string version?

It's fairly common for backing up and rewriting a progress line in
simple console programs:

for i in range(100):
    print(f"\r              \rCompleted: {i}%", end='')
    sleep(0.5)

Paul



More information about the Python-list mailing list