_repr_ methods are with double underscore

Issue #43 resolved
Johan Rosenkilde created an issue

At least the GRS decoders have omitted this.

Are we sure that it is not necessary to implement __str__ if one has __repr__?

Comments (5)

  1. David Lucas repo owner

    The goal of __repr__ is to represent without any ambiguity the object, while the goal of __str__ is to represent it in a readable way. __str__ is not necessary, but is useful when it comes to debug the formatting of a string, because it should remove special characters. It's more a "how user will see it" that a "how it is written in the code".

    For instance: str(3) : '3' str("3") : '3' repr(3) : '3' repr("3") : " '3' "

    Details : http://stackoverflow.com/questions/1436703/difference-between-str-and-repr-in-python

  2. Log in to comment