Console Newline \r

Chris
2011-05-25
2013-03-15
  • Chris

    Chris - 2011-05-25

    I'm using Pydev in Eclipse on Ubuntu Linux.

    Say I have a python script as follows:

    for i in range(101):
        print(str(i) + "% \r", end="")
    

    Running this script from terminal gives the anticipated and wanted result, a print that updates the line with the end result as follows:

    100%
    

    If I run the script in Eclipse/Pydev, the output is instead:

    0%
    1%
    2%
    ...
    100%
    

    It seems the console handles \r as a complete newline. Does anyone know a way to fix this behaviour? Thanks in advance!

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-05-26

    Unfortunately (as you saw), this is not currently possible inside of Eclipse.

    PyDev doesn't really do anything there, it just passes control of the console to Eclipse, so, Eclipse itself should take care of handling a '\r' and do what you want, but I can see some issues as it's not a real shell (and output is asynchronized).

    So, please create a bug-report at Eclipse.org asking for that to be added (and please post the link to the bug in this forum so that I can help you there).

    Cheers,

    Fabio