Golden String: A Python design pattern to salvage a function returning a string
What to do if you have a well-used API with a function returning a string, and you want to return other information without breaking the calling code?
Pass that information as attributes to the string itself! Since the standard str type does not allow it, a new class GoldenStr must be created.
In the called function
In the called function, you could use the code below to write: