What is wrong with this way of showing the progress of the function?
Question: Here is my function

    
    
    def f(task_list):
        results = []
        for task_id in task_list:
            results.append(work(task_id))
            print len(results) # show the progress
        return results
    

I use execfile() in ipython to run this function, but it seems that the
progress is showed until the whole function ends

======================= I tried again, it seems okay now...


Answer: try to force to flush stdout :

    
    
    import sys
    def f(task_list):
        results = []
        for task_id in task_list:
            results.append(work(task_id))
            print len(results) # show the progress
            sys.stdout.flush()  # this will force the system to display what is in the stdout queue
        return results
    

