Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
\r functionality
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jake  
View profile  
 More options May 17 2005, 6:17 am
Newsgroups: comp.lang.python
From: "Jake" <jacob.hu...@gmail.com>
Date: 17 May 2005 03:17:28 -0700
Local: Tues, May 17 2005 6:17 am
Subject: \r functionality
in c and c++ there is a useful way to refresh an output line in printf
and cout using \r meta command. So for example in the wget application
the progress of the download is updated on the same output line of the
screen. From an intital investigation python seems to lack this. Is
this correct?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Markus Weihs  
View profile  
 More options May 17 2005, 6:30 am
Newsgroups: comp.lang.python
From: Markus Weihs <mwe...@gmx.at>
Date: Tue, 17 May 2005 12:30:10 +0200
Local: Tues, May 17 2005 6:30 am
Subject: Re: \r functionality
Hi!

> in c and c++ there is a useful way to refresh an output line in printf
> and cout using \r meta command. So for example in the wget application
> the progress of the download is updated on the same output line of the
> screen. From an intital investigation python seems to lack this. Is
> this correct?

No. Well, I think you can't do it with print, but you can do this:

import sys
import time

signs = "|/-\\"
while 1:
    for i in signs:
        sys.stdout.write(i+"\r")
        sys.stdout.flush()
        time.sleep(0.2)

Regards, Markus


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Schüle  
View profile  
 More options May 17 2005, 7:06 am
Newsgroups: comp.lang.python
From: Daniel Schüle <u...@rz.uni-karlsruhe.de>
Date: Tue, 17 May 2005 13:06:03 +0200
Local: Tues, May 17 2005 7:06 am
Subject: Re: \r functionality

Jake wrote:
> in c and c++ there is a useful way to refresh an output line in printf
> and cout using \r meta command. So for example in the wget application
> the progress of the download is updated on the same output line of the
> screen. From an intital investigation python seems to lack this. Is
> this correct?

 >>> print "a\rb"
b
 >>>

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Duncan Booth  
View profile  
 More options May 17 2005, 7:52 am
Newsgroups: comp.lang.python
From: Duncan Booth <duncan.bo...@invalid.invalid>
Date: 17 May 2005 11:52:05 GMT
Local: Tues, May 17 2005 7:52 am
Subject: Re: \r functionality

Jake wrote:
> in c and c++ there is a useful way to refresh an output line in printf
> and cout using \r meta command. So for example in the wget application
> the progress of the download is updated on the same output line of the
> screen. From an intital investigation python seems to lack this. Is
> this correct?

>>> for i in range(10000):

...   print '\r',i,'and counting',
...
9999 and counting

(not obvious from the copy/paste of the output is that it also displayed
the intervening numbers as it counted). The important thing is to end each
print statement with a comma (or use sys.stdout.write).


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fredrik Lundh  
View profile  
 More options May 17 2005, 10:46 am
Newsgroups: comp.lang.python
From: "Fredrik Lundh" <fred...@pythonware.com>
Date: Tue, 17 May 2005 16:46:29 +0200
Local: Tues, May 17 2005 10:46 am
Subject: Re: \r functionality

"Jake" <jacob.hu...@gmail.com> wrote:
> in c and c++ there is a useful way to refresh an output line in printf
> and cout using \r meta command.

that's a control character that's printed to the terminal by printf/cout,
not a "C or C++ meta command"

to print the same character in Python, use the same character escape:

    print "\r", count,

(note that if this works or not depends on the terminal you're sending the
output to.  most ordinary terminals handle it just fine, but if you're sending
output to an IDE console window, it may not work as expected)

</F>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google