Abbreviate word.
(S: str, max: int, ellipsis: str | bool = '...')
| 61 | |
| 62 | |
| 63 | def abbr(S: str, max: int, ellipsis: str | bool = '...') -> str: |
| 64 | """Abbreviate word.""" |
| 65 | if S is None: |
| 66 | return '???' |
| 67 | if len(S) > max: |
| 68 | return isinstance(ellipsis, str) and ( |
| 69 | S[: max - len(ellipsis)] + ellipsis) or S[: max] |
| 70 | return S |
| 71 | |
| 72 | |
| 73 | def abbrtask(S: str, max: int) -> str: |
no outgoing calls