[reportlab-users] Many __repr__() methods are really __str__ methods

Robin Becker reportlab-users@reportlab.com
Thu, 13 Feb 2003 12:17:33 +0000


In article <3E4AA11A.2E42668D@email.sps.mot.com>, Norman Shelley
<Norman_Shelley-RRDN60@email.sps.mot.com> writes
>I have an application that dumps a description of how it built a pdf file so
>that one can slightly modify that description and rerun the application to get a
>new pdf file.
>
>I just noticed today that when a reportlab Table instance is used that my
>generated script fails. I looked into it and determined that the def
>__repr__(self) methods for at least the following are really more like def
>__str(self) methods.   __repr__(self) methods should output a string that Python
>can interpret and these only output strings which a human can interpret and
>Python crashes on their output with syntax errors.
>
>
>./lib/styles.py  PropertySet
>./platypus/flowables.py  KeepTogether
>./platypus/paragraph.py   Paragraph
>./platypus/tables.py  Table
.....that may be true, but I think the intention was to provide a quick
and dirty identification mechanism when repr is used rather than str.

The difficulty with strict repr is that we have styles and property sets
etc. A correct repr for a paragraph should presumably give the repr for
its style etc etc etc. That would lead to huge dumps quite often.
-- 
Robin Becker