Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30367

Re: Reducing cache/buffer for faster display

References <cmuej9-0ml.ln1@murmur.very.softly> <mailman.1522.1348783807.27098.python-list@python.org> <k42jp3$1nc$1@reader1.panix.com> <mailman.1523.1348785513.27098.python-list@python.org> <686fj9-aql.ln1@murmur.very.softly>
Date 2012-09-28 18:08 +1000
Subject Re: Reducing cache/buffer for faster display
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1544.1348819742.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Sep 28, 2012 at 10:05 AM, Rikishi42 <skunkworks@rikishi42.net> wrote:
> The scripts in question only increase numbers. But should that not be the
> case, solutions are simple enough. The numbers can be formatted to have a
> fixed size. In the case of random line contents (a list of filesnames, say)
> it's enough to create an output function that is aware of the length of the
> previously printed line, and add enough spaces to the current one to wipe
> exess content.

Yep, that's a pretty effective way to do it. One simple method to it
is to format the whole string as a single whole, then left justify it
in a field of (say) 79 characters, and output that:

msg = "Progress: %d%% (%d/%d)... %s" % (done*100/total, done, total,
current_file)
print msg.ljust(79)+"\r",
sys.stdout.flush()

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Reducing cache/buffer for faster display Rikishi42 <skunkworks@rikishi42.net> - 2012-09-27 23:57 +0200
  Re: Reducing cache/buffer for faster display Chris Angelico <rosuav@gmail.com> - 2012-09-28 08:09 +1000
    Re: Reducing cache/buffer for faster display John Gordon <gordon@panix.com> - 2012-09-27 22:25 +0000
      Re: Reducing cache/buffer for faster display Chris Angelico <rosuav@gmail.com> - 2012-09-28 08:38 +1000
        Re: Reducing cache/buffer for faster display Rikishi42 <skunkworks@rikishi42.net> - 2012-09-28 02:05 +0200
          Re: Reducing cache/buffer for faster display Chris Angelico <rosuav@gmail.com> - 2012-09-28 18:08 +1000
            Re: Reducing cache/buffer for faster display Rikishi42 <skunkworks@rikishi42.net> - 2012-09-29 02:31 +0200
      Re: Reducing cache/buffer for faster display Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-27 21:46 -0400
        Re: Reducing cache/buffer for faster display Rikishi42 <skunkworks@rikishi42.net> - 2012-09-29 02:20 +0200
          Re: Reducing cache/buffer for faster display Hans Mulder <hansmu@xs4all.nl> - 2012-09-29 14:32 +0200
          Re: Reducing cache/buffer for faster display Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-29 14:12 -0400
    Re: Reducing cache/buffer for faster display Rikishi42 <skunkworks@rikishi42.net> - 2012-09-28 02:15 +0200

csiph-web