How to continuously updating the display in two different place in Python
Question: I know how to print one line in same plase but I want to print same place from
thread only.

Now I'm getting:

>
>     OK 97035
>  

I want to get:

>
>     OK 97035
>     OK 92035
>  

First line is from t1 thread, second from t2 thread. Anyone know how to do it
?

This is sample code.

    
    
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import string, threading
    
    def test():
        for i in range(0, 100000):
            print "\rOK "+str(i),
    
    jczyd= ['1', '2']
    
    
    while True:
            for i in jczyd:
                    if i == '1':
                            #print i
                            t1 = threading.Thread(target=test, args = ())
                            t1.daemon = True
                            t1.start()
                    elif i == '2':
                            #print i
                            t2 = threading.Thread(target=test, args = ())
                            t2.daemon = True
                            t2.start()
            t1.join()
            t2.join()
    


Answer: Actually, this is trickier than you might think.

The problem is that there's no character in plain ASCII that you can use to
update two separate lines of text simultaneously. `\r` only lets you erase one
line.

If you want to update two lines you will have to use a platform-specific
method, like ANSI escape codes, or use `curses` to control the terminal in a
more general way.

On most UNIX systems, you can do this with code like this:

    
    
    print '\x1b[%dH%s\x1b[K' % (thread_id, i)
    

which sets the cursor to the `thread_id`th line, prints `i`, then erases the
rest of the line.

