@ -818,7 +818,7 @@ player = Player(point, direction) <span class="hljs-comment">#
<ul>
<li><strong>Return value of repr() should be unambiguous and of str() readable.</strong></li>
<li><strong>Return value of str() should be readable and of repr() unambiguous.</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>
<div><h2id="array"><ahref="#array"name="array">#</a>Array</h2><p><strong>List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> array <spanclass="hljs-keyword">import</span> array
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <coll_of_nums>) <spanclass="hljs-comment"># Array from collection of numbers.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <bytes>) <spanclass="hljs-comment"># Array from bytes object.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <array>) <spanclass="hljs-comment"># Treats array as a sequence of numbers.</span>
<array>.fromfile(<file>, n_items) <spanclass="hljs-comment"># Appends items. Also frombytes().</span>
<file>.write(<array>) <spanclass="hljs-comment"># Writes array to the binary file.</span>
</code></pre></div>
<pre><codeclass="python language-python hljs"><array> = array(<spanclass="hljs-string">'<typecode>'</span>, <coll_of_nums>) <spanclass="hljs-comment"># Array from collection of numbers.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <bytes>) <spanclass="hljs-comment"># Array from bytes object.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <array>) <spanclass="hljs-comment"># Treats array as a sequence of numbers.</span>
<array>.fromfile(<file>, n_items) <spanclass="hljs-comment"># Appends items from the binary file.</span>
</code></pre>
<pre><codeclass="python language-python hljs"><bytes> = bytes(<array>) <spanclass="hljs-comment"># Converts array to a bytes object.</span>
<file>.write(<array>) <spanclass="hljs-comment"># Writes array to the binary file.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <mview>) <spanclass="hljs-comment"># Treats mview as a sequence of numbers.</span>
<file>.write(<mview>) <spanclass="hljs-comment"># Writes mview to the binary file.</span>
</code></pre>
<pre><codeclass="python language-python hljs"><list> = list(<mview>) <spanclass="hljs-comment"># Returns a list of ints or floats.</span>
<str> = str(<mview>, <spanclass="hljs-string">'utf-8'</span>) <spanclass="hljs-comment"># Treats mview as a bytes object.</span>
<div><h2id="deque"><ahref="#deque"name="deque">#</a>Deque</h2><p><strong>A thread-safe list with efficient appends and pops from either side. Pronounced "deck".</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> collections <spanclass="hljs-keyword">import</span> deque
<deque> = deque(<collection>) <spanclass="hljs-comment"># Also `maxlen=None`.</span>