2.2.42. czekitout.convert.to_str_from_str_like
- to_str_from_str_like(obj, obj_name)[source]
Convert string-like input object to an instance of the class str.
If the input object is not string-like, then a TypeError exception is raised with the message:
The object ``<obj_name>`` must be an instance of the class `str` or `bytes`.
where <obj_name> is replaced by the contents of the string
obj_name
.If the input object is an instance of the class bytes, then said object is decoded to an instance of the class str via
obj.decode("utf-8")
.- Parameters:
- objany type
Input object.
- obj_namestr
Name of the input object.
- Returns:
- resultstr
The object resulting from the conversion.