Curses programming, threads?

Bartlomiej Rymarski bart at
Fri Dec 3 11:34:05 CET 2004


I'm writing this little program, and I've came across a function
that I need to call. Since the execution of the function takes a 
real long time I want to put a timer, or an animated 'loading' 
screen (it would be best if it was a progressbar). The questions is
how to make two commands to run at the same time. 

I'm talking about a function which (for example) is connecting to
the database, and while it's connecting I would like to display a
nice loading animation. It could be a ascii sequence like this:
 [/] [-] [\] [|] [/] [-] [\] [|]

I could write a function like this:

def function:
	print "[/]"
	print "[-]"
	print "[\]"

But is this really the way other programs work? I don't think so.
And they don't use threads AFAIK. How can I accomplish something 
like this?

It would be best if I could operate with like this:

def function:
	do loader() while

And the loader() function would run in a loop until connect_db() is 
is finished. Is that possible in python? Or are there any other,
better ways to do it?

Thanks a lot.


Bartek Rymarski <bart at>
$ %blow
bash: fg: %blow: no such job

More information about the Python-list mailing list