On 12 February 2013 15:48, Michael Hanselmann <[email protected]> wrote:
> 2013/2/11 Bernardo Dal Seno <[email protected]>:
>> On 6 February 2013 14:38, Michael Hanselmann <[email protected]> wrote:
>>> Having a readable representation makes debugging easier.
>>> ---
>>>  qa/qa_config.py | 22 ++++++++++++++++++++++
>>>  1 file changed, 22 insertions(+)
>>
>> I'm not sure this is a good idea. It's code that it's never exercised,
>> there is nothing that makes sure that the representation is consistent
>> with the actual object (someone could add/remove methods...), so it
>> can even be harmful. A more general function to display an object
>> would make more sense to me (I'm assuming that there's nothing like
>> that in the Python library).
>
> “__repr__” *is* the standard function for displaying an object in
> Python: <http://docs.python.org/2/reference/datamodel.html#object.__repr__>.

I mean a more general in the sense that doesn't contain explicit
references to the object members. If someone add an attribute or
change its type this function might silently break. Can you please at
least add some assertions?

Bernardo

Reply via email to