-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
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()
foobar elapsed time: 1.000 seconds
>>> t = Timer()
>>> t.start()
>>> time.sleep(1)
>>> t.stop()
Elapsed time: 1.000 secondsThis might be achieved with the following __post_init__ function:
def __post_init__(self):
if self.name is None:
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").
Metadata
Metadata
Assignees
Labels
No labels