Friday, August 19, 2022

Printing from within an embedded Python program


Hi

I am using an embedded Python program to take an average of a large number of spectra.
I want to continuously print the number of averaged spectra so that output happens on a same line, always overwriting the previous number. So not printing each number on a separate line.

In Python you can do it in the following way:

>for i in range(100000):
...   print('Number of spectra averaged  ', i, end='\r')

However, that does not work from within an embedded Python program, each number is on its own line, which is very time consuming.

How to print on a same line, overwriting previous output ?
I am using GRC 3.9.5.0 (Python 3.8.10) on Ubuntu 12.04.4

Cheers, Kimmo


No comments:

Post a Comment