On 27/09/2010 17:11, Thierry Tung wrote:
Hello tutor at python.org.
How can I write strings to the console in a way that will give the same result
in Python 3 and Python 2?
I tried sys.stdout.write('hello') on Microsoft vista.
with python 3.1.2
sys.stdout.write('hello')
hello5
with py
Hello tutor at python.org.
How can I write strings to the console in a way that will give the same result
in Python 3 and Python 2?
I tried sys.stdout.write('hello') on Microsoft vista.
with python 3.1.2
>>>sys.stdout.write('hello')
hello5
>>>
with python 2.7
>>>sys.stdout.write('hello')
hel
> Hmm, just have to say something about the old days when
> 'carriage return' and 'line feed' really meant something :-)
Yep, and on a teleype were two physically separate keys!
Alan G
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mail
Oliver Maunder wrote:
> Just what I needed - thanks everyone. I never realised '\r' was actually
> good for something other than Windows line breaks!
Hmm, just have to say something about the old days when 'carriage return' and
'line feed' really meant something :-)
Kent
__
- Original Message -
From: "Roel Schroeven" <[EMAIL PROTECTED]>
To:
Sent: Wednesday, October 05, 2005 2:53 PM
Subject: Re: [Tutor] Console output
> Oliver Maunder wrote:
>> Does anyone know how I can update a line of console output without
>> creatin
> 14% [===> ] 344,192 16.28K/s ETA 02:19
>
> All the figures and the progress bar get continously updated. The only way
> I
> know of sending output to the console is to use print or
> sys.stdout.write(),
> but that would give me:
> 14% [===> ] 344,192 16.28K/s ETA 02:19
> 18% [=>
Just what I needed - thanks everyone. I never realised '\r' was actually good for something other than Windows line breaks!
Olly
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
This might help. Never used it though.
Johan
Christian Wyglendowski wrote:
> -Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Oliver Maunder
Sent: Wednesday, October 05, 2005 1:13 PM
To: tutor@python.org
Subject: [Tutor] Console output
D
>>> import sys
>>> import time
>>> myList=range(10)
>>> for x in myList:
... sys.stdout.write(str(x) + "\r")
... sys.stdout.flush()
... time.sleep(1)
The "\r" causes a return without a newline feed.
Flush forces the text to be output (instead of getting buffered)
Enjoy!
Todd Maynard
Oliver Maunder wrote:
> Does anyone know how I can update a line of console output without
> creating a new line? I'm not explaning this too well, so here's an example.
>
> When you download a file with wget, the console display looks like this:
>
> 14% [===>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Oliver Maunder
> Sent: Wednesday, October 05, 2005 1:13 PM
> To: tutor@python.org
> Subject: [Tutor] Console output
>
> Does anyone know how I can update a line of console ou
Does anyone know how I can update a line of console output without
creating a new line? I'm not explaning this too well, so here's an
example.
When you download a file with wget, the console display looks like this:
14%
[===>
] 344,192
12 matches
Mail list logo