<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'help=<str>'</span></code> to set argument description that will be displayed in help message.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'default=<el>'</span></code> to set the default value.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'type=FileType(<mode>)'</span></code> for files. Also accepts 'encoding', but not 'newline'.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'type=FileType(<mode>)'</span></code> for files. Accepts 'encoding', but 'newline' is always None.</strong></li>
</ul>
<div><h2id="open"><ahref="#open"name="open">#</a>Open</h2><p><strong>Opens the file and returns a corresponding file object.</strong></p><pre><codeclass="python language-python hljs"><file> = open(<path>, mode=<spanclass="hljs-string">'r'</span>, encoding=<spanclass="hljs-keyword">None</span>, newline=<spanclass="hljs-keyword">None</span>)
<pre><codeclass="python language-python hljs"><Path> = <Path>.parent <spanclass="hljs-comment"># Returns Path without the final component.</span>
<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>
</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 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 Dialect object.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'delimiter'</span></code> - A one-character string used to separate fields.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'quotechar'</span></code> - Character for quoting fields that contain special characters.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'skipinitialspace'</span></code> - Whether whitespace after delimiter gets stripped by reader.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'lineterminator'</span></code> - How writer terminates rows. Reader is hardcoded to '\n', '\r', '\r\n'.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'quoting'</span></code> - Controls the amount of quoting: 0 - as necessary, 1 - all.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'quoting'</span></code> - 0: As necessary, 1: All, 2: All but numbers which are read as floats, 3: None.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'escapechar'</span></code> - Character for escaping quotechars if doublequote is False.</strong></li>
<tuple> = unpack(<spanclass="hljs-string">'<format>'</span>, <bytes>) <spanclass="hljs-comment"># Use iter_unpack() for iterator of tuples.</span>
<div><h3id="format-2">Format</h3><div><h4id="forstandardtypesizesandmanualalignmentpaddingstartformatstringwith">For standard type sizes and manual alignment (padding) start format string with:</h4><ul>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'='</span></code> - system's byte order (usually little-endian)</strong></li>
</ul></div></div><div><h4id="integertypesuseacapitalletterforunsignedtypeminimumandstandardsizesareinbrackets">Integer types. Use a capital letter for unsigned type. Minimum and standard sizes are in brackets:</h4><ul>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'x'</span></code> - pad byte</strong></li>
</code></pre>
<h3id="format-2">Format</h3><div><h4id="forstandardtypesizesandmanualalignmentpaddingstartformatstringwith">For standard type sizes and manual alignment (padding) start format string with:</h4><ul>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'='</span></code> - System's byte order (usually little-endian).</strong></li>
</ul><div><h4id="besidesnumberspackandunpackalsosupportbytesobjectsaspartoftheseqence">Besides numbers, pack() and unpack() also support bytes objects as part of the seqence:</h4><ul>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'c'</span></code> - A bytes object with single element. Use <codeclass="python hljs"><spanclass="hljs-string">'x'</span></code> for pad byte.</strong></li>
<li><strong><codeclass="apache hljs"><spanclass="hljs-section">'<n>s'</span><spanclass="hljs-attribute"></span></code> - A bytes object with n elements.</strong></li>
</ul></div></div><div><div><h4id="integertypesuseacapitalletterforunsignedtypeminimumandstandardsizesareinbrackets">Integer types. Use a capital letter for unsigned type. Minimum and standard sizes are in brackets:</h4><ul>
<div><h4id="3ifneithernonmatchingdimensionhassize1raiseanerror">3. If neither non-matching dimension has size 1, raise an error.</h4><div><h3id="example-2">Example</h3><div><h4id="foreachpointreturnsindexofitsnearestpoint010608121">For each point returns index of its nearest point (<codeclass="python hljs">[<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.6</span>, <spanclass="hljs-number">0.8</span>] => [<spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>, <spanclass="hljs-number">1</span>]</code>):</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>points = np.array([<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.6</span>, <spanclass="hljs-number">0.8</span>])
<div><h4id="3ifneithernonmatchingdimensionhassize1raiseanerror">3. If neither non-matching dimension has size 1, raise an error.</h4><div><h3id="example-1">Example</h3><div><h4id="foreachpointreturnsindexofitsnearestpoint010608121">For each point returns index of its nearest point (<codeclass="python hljs">[<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.6</span>, <spanclass="hljs-number">0.8</span>] => [<spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>, <spanclass="hljs-number">1</span>]</code>):</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>points = np.array([<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.6</span>, <spanclass="hljs-number">0.8</span>])