Python 3 print function does not work properly in Python consoles
See original GitHub issueDescription of your problem
I am running python 2.7, but uses the print function from python3 in order to use the overwrite functionality. However this does not work porperly in the spyder console.
What steps will reproduce the problem? An example:
from __future__ import print_function
import time
import sys
for i in range(10):
print(i,end='\r')
time.sleep(0.5)
sys.stdout.flush()
What is the expected output? What do you see instead? This should not change the line, but the numbers should simply be overwritten. However in the spyder console, a linebreak seems to be inserted, such that the output is: 0 1 2 3 4 5 etc.
In the IPython console in Spyder the output is 0123456789
Please provide any additional information below I am using the latest spyder3 update, but spyder2 had the same problem
Versions and main components
- Spyder Version: Spyder 3.0.0.dev0 beta6, Qt 5.6.0, PyQt5 5.6
- Python Version: Python 2.7.11 64bits
- Operating system: Linux
Dependencies
jedi >=0.8.1 : 0.9.0 (OK) matplotlib >=1.0 : 1.5.1 (OK) nbconvert >=4.0 : 4.1.0 (OK) numpy >=1.7 : 1.10.4 (OK) pandas >=0.13.1 : 0.18.0 (OK) pep8 >=0.6 : 1.7.0 (OK) psutil >=0.3 : 4.1.0 (OK) pyflakes >=0.5.0 : 1.1.0 (OK) pygments >=2.0 : 2.1.1 (OK) pylint >=0.25 : 1.5.4 (OK) qtconsole >=4.2.0: 4.2.0 (OK) rope >=0.9.4 : 0.9.4 (OK) sphinx >=0.6.6 : 1.3.5 (OK) sympy >=0.7.3 : 1.0 (OK)
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@AzraelDD
As a workaround, you can write instead:
This works for me both in the Python, IPython, and qtconsole used by Spyder.
This is something I’ve stumbled upon also in the past. It seems to me this is a problem with the QtConsole not with Spyder, so maybe a new issue should be opened there?
In Spyder:
In a bare QtConsole:
In a notebook: