-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backspace (\b) and carriage return (\r) characters are not printed correctly in the console #195
Comments
From christop...@gmail.com on 2010-09-15T14:38:19Z Tested again on spyder 1.1.6. Using the example I get 'yesno' as output. Backspace is not printed. |
From ccordoba12 on 2011-04-15T07:00:29Z I can confirm that this still happens in Spyder 2.0, but now I get "Yes°no" Summary: Backspace character is printed incorrectly in the console |
From ccordoba12 on 2011-05-15T08:05:07Z I've been investigating this issue and it turns out it's not an encoding problem or anything related. To the best of my understanding, to print correctly these characters you have to be working on a proper terminal (bash or cmd.exe) and not inside a GUI. I've tried to print them on the python interpreters I have at hand (ipython-qtconsole, wing-ide, Eric, IDLE and ipython-notebook) and I can confirm the same problem in all of them. It also occurs in environments not based on Python, for example in Eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=76936 This issue could be solved by emulating the terminal behavior inside Spyder. We could check if the user wants to print a string that contains these characters and preparse the input before sending it to the console, so that the result be the expected. But for that to happen I would like to hear some good reasons of those who reported the problem, to see if it's really worth the effort to implement this feature. Summary: Backspace (\b) and carriage return (\r) characters are not printed correctly in the console |
From ccordoba12 on 2011-05-15T08:06:23Z issue #645 has been merged into this issue. |
From ccordoba12 on 2011-05-15T19:21:05Z Labels: Cat-Console |
From ays...@gmail.com on 2012-10-08T08:16:45Z Terminal-like support for \b and \r characters provides a simple way to make animations in standard out (using sys.stdout.write() ), such as a progress bar for a download (think wget). In such a use, it is not sufficient to only modify isolated strings that contains these characters, but you also need to remember where the cursor is so that a subsequent call to sys.stdout.write() starts at the intended point. |
From ccordoba12 on 2012-10-08T10:27:39Z I think this was fixed for the IPython qtconsole some time ago. I don't think we are going to fix this for our Python console, because it seems to much trouble for what you can get. But if someone wants to help us with this and send a patch, then we'll be happy to review it and add it to our tree. |
From bzac...@gmail.com on 2014-02-18T14:29:01Z I think its worth the effort. |
From ccordoba12 on 2014-02-19T12:49:26Z Please send us a pull request if you consider it important enough or just use one of our IPython consoles (which I know for sure have this functionality implemented). Status: HelpNeeded |
From ccordoba12 on 2014-12-18T08:45:14Z Status: Accepted |
From ccordoba12 on 2014-12-18T09:01:48Z This issue was closed by revision ce3d4d0af8a5 Status: Fixed |
Hello there, this issue has been closed years ago, but it still exists for me. I was wondering if I should create a new issue, but I give it a try here. Example code: import time
for i in range(100):
print(i, end='\r') # OK
print()
for i in range(1000):
print(i, end='\r') # OK
print()
for i in range(10000):
print(i, end='\r') # Fail
print()
for i in range(10):
time.sleep(0.2)
print(i, end='\r') # Fail Output in external system terminal (expected output):
Output in IPython console in Spyder:
Printing progress information in my loops is important to me, and therefore I cannot use the Spyder console for most of my scripts. Why can't I find more complaints about this? Am I missing something? Thanks to all contributers for their work & regards! |
@jnettels, this was fixed for our (old and now removed) Python console. However, this is still an issue in our IPython console. The problem was reported alredy in jupyter/qtconsole#272. If you have time, please take a look at qtconsole's code to see if you can help us to fix it (it's low priority for us right now). |
Don't know if it's helpful for troubleshooting, but I was able to get the desired \r behavior in the Spyder console by using \r in both the object and end arguments for print. This produces desired overwriting of the output:
This incorrectly produces the numbers 1 through 10 each on a new line, without overwriting:
This incorrectly produces the numbers 1 through 10 all on the same line, without overwriting:
|
What I noticed so far: This is actually normal that the following produces new lines (this is also the case with a regular terminal with Ipython):
This is because the default Thus, the best workaround so far is the following (working identically as expected in the Spyder Ipython console and a regular terminal Ipython console):
It seems that |
From code3rea...@gmail.com on 2010-04-10T13:59:33Z
What steps will reproduce the problem?
1.type: print("Yes\bno") 2. 3. What is the expected output? What do you see instead? expected: yeno
observed: yes[checkmarkcharacter]no What version of the product are you using? On what operating system? 1.1.0beta1
Please provide any additional information below
. seen screenshot
Attachment: spyder_backspace.png
Original issue: http://code.google.com/p/spyderlib/issues/detail?id=195
The text was updated successfully, but these errors were encountered: