I have an abstract class (called AbstractSparseVector) whose most important feature is a dictionary (called dict). So in the __repr__ function I just call str(self.dict).
Now the implementing subclasses all have different types of values in that dictionary. One just has a float and the other a tuple containing 3 elements: boolean, string, string. The strings of the latter class can contain special characters such as 'ö' but printing my AbstractSparseVector changes that character into '\xc3\xb6g'.
Now from this answer I understand that this happens because the dictionary calls the Tuple's __repr__ which returns the wrong '\xc3\xb6g' characters. If it called __str__ it would print correctly.
Is there any pretty way to achieve this?
So far my only solution is to iterate over the key, value pairs of the dictionary then over the tuple so that I can get the __str__ representation of these strings rather than the __repr__ presentation and piecing my own output string togeter.
That is ugly and also impractical because every subclass of AbstractSparseVector will have to implement its own __repr__ class.