<li><strong>Return value of repr() should be unambiguous and of str() readable.</strong></li>
<li><strong>If only repr() is defined, it will also be used for str().</strong></li>
<li><strong>Methods decorated with <codeclass="python hljs"><spanclass="hljs-string">'@staticmethod'</span></code> do not receive 'self' nor 'cls' as their first arg.</strong></li>
</ul>
<div><h4id="strusecases">Str() use cases:</h4><pre><codeclass="python language-python hljs">print(<el>)
file.writeframes(<spanclass="hljs-string">b''</span>.join(get_bytes(f) <spanclass="hljs-keyword">for</span> f <spanclass="hljs-keyword">in</span> float_samples))
</code></pre></div>
<div><h3id="examples-1">Examples</h3><div><h4id="savesasinewavetoamonowavfile">Saves a sine wave to a mono WAV file:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> math <spanclass="hljs-keyword">import</span> pi, sin
<div><h3id="examples-1">Examples</h3><div><h4id="savesa440hzsinewavetoamonowavfile">Saves a 440 Hz sine wave to a mono WAV file:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> math <spanclass="hljs-keyword">import</span> pi, sin
samples_f = (sin(i * <spanclass="hljs-number">2</span> * pi * <spanclass="hljs-number">440</span> / <spanclass="hljs-number">44100</span>) <spanclass="hljs-keyword">for</span> i <spanclass="hljs-keyword">in</span> range(<spanclass="hljs-number">100000</span>))