A small quality-of-life improvement would be if the default format string included the name attribute by default.
>>>t=Timer('foobar')
>>>t.start()
>>>time.sleep(1)
>>>t.stop()
foobarelapsedtime: 1.000seconds>>>t=Timer()
>>>t.start()
>>>time.sleep(1)
>>>t.stop()
Elapsedtime: 1.000secondsThis might be achieved with the following __post_init__ function:
def__post_init__(self):
ifself.nameisNone:
self.text="Elapsed time: {:0.4f} seconds"else:
self.text="{name} elapsed time {:0.4f} seconds"Alternatively, name could just have a non-None default value (e.g. "Timer" or "Elapsed").
A small quality-of-life improvement would be if the default format string included the name attribute by default.
This might be achieved with the following
__post_init__function:Alternatively, name could just have a non-None default value (e.g. "Timer" or "Elapsed").