sleep() function, perhaps.

Skip Montanaro skip at
Tue Nov 25 16:00:56 CET 2003

    Ryan> I want to have a row of periods, separated by small, say, .5
    Ryan> second intervals between each other. Thus, for example, making it
    Ryan> have the appearance of a progress "bar".

You might find my progress module at

a good starting point.  Something like

    import progress, time
    ticker = progress.Progress(major=1, minor=1, majormark='.')
    while True:

running in a separate thread should do what you want.

In many situations you want to actually measure progress of some
computation.  If you can wedge in a call to ticker.tick() on each pass of
your main computation loop:

    import progress, time
    ticker = progress.Progress()
    while some_condition_holds:

you can watch your computation progress.

This is particularly helpful if you know how many passes you need to make
around the loop:

    import progress, time
    number_of_passes = 10000
    ticker = progress.Progress(title="(%d)" % number_of_passes)
    for i in xrange(number_of_passes):

The title displayed tells you how many loops to expect and the dots and
numbers measure your progress:

(10000): .........1.........2.........3.........4

and when you delete the ticker or it goes out-of-scope, it displays the
total number of ticks (which might be lower if the loop was exited

There are more bells and whistles.  Check the Progress class docstring for
full details.


More information about the Python-list mailing list