Python: easy way to show progress

I use this quite often to indicate how long a loop takes:

PYTHON:
  1. for i, entry in enumerate(entries):
  2.         # do something
  3.         print "\r%s/%s" % (i, len(entries)),
  4.         sys.stdout.flush()

It shows
1/13
2/13
...
on the same line (similar to a progress bar)

Leave a Reply