<li><strong>File must be opened with a <codeclass="python hljs"><spanclass="hljs-string">'newline=""'</span></code> argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!</strong></li>
<li><strong>File must be opened with a <codeclass="python hljs"><spanclass="hljs-string">'newline=""'</span></code> argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!</strong></li>
<li><strong>Open existing file with <codeclass="python hljs"><spanclass="hljs-string">'mode="w"'</span></code> to overwrite it or <codeclass="python hljs"><spanclass="hljs-string">'mode="a"'</span></code> to append to it.</strong></li>
<li><strong>Open existing file with <codeclass="python hljs"><spanclass="hljs-string">'mode="a"'</span></code> to append to it or <codeclass="python hljs"><spanclass="hljs-string">'mode="w"'</span></code> to overwrite it.</strong></li>
</ul>
</ul>
<div><h3id="parameters">Parameters</h3><ul>
<div><h3id="parameters">Parameters</h3><ul>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'dialect'</span></code> - Master parameter that sets the default values. String or a 'csv.Dialect' object.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'dialect'</span></code> - Master parameter that sets the default values. String or a 'csv.Dialect' object.</strong></li>
<file>.write(<array>) <spanclass="hljs-comment"># Writes array's memory to binary file.</span>
<file>.write(<array>) <spanclass="hljs-comment"># Writes array's memory to binary file.</span>
</code></pre>
</code></pre>
<div><h2id="memoryview"><ahref="#memoryview"name="memoryview">#</a>Memory View</h2><p><strong>A sequence object that points to the memory of another bytes-like object. Each element can reference a single or multiple consecutive bytes, depending on format. Order and number of elements can be changed with slicing.</strong></p><pre><codeclass="python language-python hljs"><mview> = memoryview(<bytes/bytearray/array>) <spanclass="hljs-comment"># Immutable if bytes is passed, else mutable.</span>
<div><h2id="memoryview"><ahref="#memoryview"name="memoryview">#</a>Memory View</h2><p><strong>A sequence object that points to the memory of another bytes-like object. Each element can reference a single or multiple consecutive bytes, depending on format. Order and number of elements can be changed with slicing.</strong></p><pre><codeclass="python language-python hljs"><mview> = memoryview(<bytes/bytearray/array>) <spanclass="hljs-comment"># Immutable if bytes is passed, else mutable.</span>
<obj> = <mview>[index] <spanclass="hljs-comment"># Returns int/float. Bytes if format is 'c'.</span>
<obj> = <mview>[index] <spanclass="hljs-comment"># Returns int or float. Bytes if format is 'c'.</span>
<mview> = <mview>[<slice>] <spanclass="hljs-comment"># Returns memoryview with rearranged elements.</span>
<mview> = <mview>[<slice>] <spanclass="hljs-comment"># Returns memoryview with rearranged elements.</span>
<mview> = <mview>.cast(<spanclass="hljs-string">'<typecode>'</span>) <spanclass="hljs-comment"># Only works between B/b/c and other types.</span>
<mview> = <mview>.cast(<spanclass="hljs-string">'<typecode>'</span>) <spanclass="hljs-comment"># Only works between B/b/c and other types.</span>
<mview>.release() <spanclass="hljs-comment"># Releases memory buffer of the base object.</span>
<mview>.release() <spanclass="hljs-comment"># Releases memory buffer of the base object.</span>
</code></pre></div>
</code></pre></div>
<pre><codeclass="python language-python hljs"><bytes> = bytes(<mview>) <spanclass="hljs-comment"># Returns a new bytes object.</span>
<pre><codeclass="python language-python hljs"><bytes> = bytes(<mview>) <spanclass="hljs-comment"># Returns a new bytes object. Also bytearray().</span>
<bytes> = <bytes>.join(<coll_of_mviews>) <spanclass="hljs-comment"># Joins memoryviews using bytes as a separator.</span>
<bytes> = <bytes>.join(<coll_of_mviews>) <spanclass="hljs-comment"># Joins memoryviews using bytes as a separator.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <mview>) <spanclass="hljs-comment"># Treats memoryview as a sequence of numbers.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <mview>) <spanclass="hljs-comment"># Treats memoryview as a sequence of numbers.</span>
<file>.write(<mview>) <spanclass="hljs-comment"># Writes `bytes(<mview>)` to the binary file.</span>
<file>.write(<mview>) <spanclass="hljs-comment"># Writes `bytes(<mview>)` to the binary file.</span>