flexstr(arg, *args, force=True, join='')[source]#

Try converting any object to a “regular” string (i.e. str), but proceed if it fails. Note: this function calls repr() rather than str() to ensure a more robust representation of objects.

  • arg (any) – the object to convert to a string

  • args (list) – additional arguments

  • force (bool) – whether to force it to be a string

  • join (str) – if multiple arguments are provided, the character to use to join


sc.flexstr(b'foo', 'bar', [1,2]) # Returns 'foobar[1, 2]'

New in version 3.0.0: handle multiple inputs