擅长:python、mysql、java
<p>除了<code>pprint.pprint</code>,<code>pprint.pformat</code>对于使<code>__repr__</code>s可读非常有用。我的复合物<code>__repr__</code>通常是这样的:</p>
<pre><code>def __repr__(self):
from pprint import pformat
return "<ClassName %s>" % pformat({"attrs":self.attrs,
"that_i":self.that_i,
"care_about":self.care_about})
</code></pre>