Something like ``` def ensure_str(bytes_or_str, encoding=None): return bytes.decode(encoding) if type(bytes_or_str) is bytes else bytes_or_str ``` It doesn't seem like there's any single expression to do this normally. https://stackoverflow.com/questions/7585435/best-way-to-convert-string-to-bytes-in-python-3
Something like
It doesn't seem like there's any single expression to do this normally.
https://stackoverflow.com/questions/7585435/best-way-to-convert-string-to-bytes-in-python-3