You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,22 @@ Note that the strings used by `text` are **not** f-strings. Instead they are use
71
71
t = Timer(text=f"{__file__}: {{:.4f}}")
72
72
```
73
73
74
+
`text` is also allowed to be a callable like a function or a class. If `text` is a callable, it is expected to require one argument: the number of seconds elapsed. It should return a text string that will be logged using logger:
75
+
76
+
```python
77
+
t = Timer(text=lambdasecs: f"{secs /86400:.0f} days")
78
+
```
79
+
80
+
This allows you to use third-party libraries like [`humanfriendly`](https://pypi.org/project/humanfriendly/) to do the text formatting:
0 commit comments