Python has options to reset the cursor position and flush output to prevent output from scrolling in the console e.g.
print("\r this will be over written by the next line",flush=true)
Is there something similar in julia?
Python has options to reset the cursor position and flush output to prevent output from scrolling in the console e.g.
print("\r this will be over written by the next line",flush=true)
Is there something similar in julia?
Try it and see:
julia> print("Over"); print("\rand over"); print("\rAgain....")
Again....
As for the flushing, see flush()
.
There are two different concepts here that from your question it sounds like youâre conflating.
'\r'
moved the carriage (the part that printed the letters) back to the beginning of the line. The Newline character '\n'
moved the carriage down to the next line (fn1). So if you print the â\râ character, it tells the terminal to move the cursor to the beginning of the line, so then the characters you print start overwriting whatâs there. This behavior isnât specific to Python or Julia, itâs a feature of the terminal (fn2). You can see this also if you print fewer characters than whatâs already in the line:print("Teletype\r"); for _ in 1:8; sleep(0.25); print("-") end
This is awesome in a REPL, thanks! Could this also be done in a Jupyter notebook?