I'm catching ctrl-c with a signal handler and was wondering if there is a nicer way to hide the ^C that is printed to terminal than go os.system("\b") or similar. I only really care about Unix.
def read(self, time_s):
setup = ['Sensor', 'sensors', '\x00']
# Closure for signal handler to allow access to self
def sigintHandler(*args):
self.close()
sys.stdout.write('\b\b\r') # Current solution
sys.stdout.flush()
sys.exit(0)
signal.signal(signal.SIGINT,sigintHandler)
My current solution is above
Using print('\b\b\r')
will clear the annoying ^C
from the output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With