macpie.strtools.add_suffix#

macpie.strtools.add_suffix(s: str, suffix: str, max_length: int = -1)#

Add a suffix to a string, optionally specifying a maximum string length and giving priority to the suffix if maximum string length is reached.

>>> add_suffix("testing", "suffix", 7)
"tsuffix"
>>> add_suffix("testing", "suffix", 8)
"tesuffix"
>>> add_suffix("testing", "suffix", 9)
"tessuffix"
Parameters:
  • s – string

  • suffix – suffix to append to s

  • max_length – maximum string length of result, giving priority to the suffix