Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 42141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:17:29+00:00 2026-05-10T15:17:29+00:00

I am writing a little application to download files over http (as, for example,

  • 0

I am writing a little application to download files over http (as, for example, described here).

I also want to include a little download progress indicator showing the percentage of the download progress.

Here is what I came up with:

     sys.stdout.write(rem_file + '...')         urllib.urlretrieve(rem_file, loc_file, reporthook=dlProgress)      def dlProgress(count, blockSize, totalSize):       percent = int(count*blockSize*100/totalSize)       sys.stdout.write('%2d%%' % percent)       sys.stdout.write('\b\b\b')       sys.stdout.flush() 

Output: MyFileName… 9%

Any other ideas or recommendations to do this?

One thing that’s somewhat annoying is the blinking cursor in the terminal on the first digit of the percentage. Is there a way to prevent this? Is there a way to hide the cursor?

EDIT:

Here a better alternative using a global variable for the filename in dlProgress and the ‘\r’ code:

     global rem_file # global variable to be used in dlProgress      urllib.urlretrieve(rem_file, loc_file, reporthook=dlProgress)      def dlProgress(count, blockSize, totalSize):       percent = int(count*blockSize*100/totalSize)       sys.stdout.write('\r' + rem_file + '...%d%%' % percent)       sys.stdout.flush() 

Output: MyFileName…9%

And the cursor shows up at the END of the line. Much better.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:17:30+00:00Added an answer on May 10, 2026 at 3:17 pm

    There’s a text progress bar library for python at http://pypi.python.org/pypi/progressbar/2.2 that you might find useful:

    This library provides a text mode progressbar. This is tipically used to display the progress of a long running operation, providing a visual clue that processing is underway.

    The ProgressBar class manages the progress, and the format of the line is given by a number of widgets. A widget is an object that may display diferently depending on the state of the progress. There are three types of widget: – a string, which always shows itself; – a ProgressBarWidget, which may return a diferent value every time it’s update method is called; and – a ProgressBarWidgetHFill, which is like ProgressBarWidget, except it expands to fill the remaining width of the line.

    The progressbar module is very easy to use, yet very powerful. And automatically supports features like auto-resizing when available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 257k
  • Answers 257k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer On Unix, when you need a thread to wait for… May 13, 2026 at 10:40 am
  • Editorial Team
    Editorial Team added an answer Serialize is a better option than JSON for storing PHP… May 13, 2026 at 10:40 am
  • Editorial Team
    Editorial Team added an answer using namespace x; is a very bad idea, since you… May 13, 2026 at 10:40 am

Related Questions

I am writing a simple C++ application which might be installed on Linux or
I am writing a desktop application and trying to decide between using AIR (FLex)
I am looking to start writing a sophisticated application in JavaScript to run on
A little setup: Our shop has a mixture of different platforms. Almost all of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.