Capture the output from function in real time python
问题 I didn't find quite what I was looking for. I want to obtain the output (stdout) from a python function in real time. The actual problem is that I want to plot a graph (with cplot from sympy) with a progress bar in my UI. The argument verbose makes cplot output the progress to stdout. sympy.mpmath.cplot(lambda z: z, real, imag, verbose=True) The output would be something like: 0 of 71 1 of 71 2 of 71 ... And so on. I want to capture line by line so I can make a progress bar. (I realize this