/usr/share/doc/python-bitstring-doc/html/constbitstream.html is in python-bitstring-doc 3.1.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | <!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The ConstBitStream class — bitstring documentation</title>
<link rel="stylesheet" href="_static/bizstyle.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '3.1.4',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/bizstyle.js"></script>
<link rel="top" title="bitstring documentation" href="index.html" />
<link rel="up" title="Reference" href="reference.html" />
<link rel="next" title="The BitStream class" href="bitstream.html" />
<link rel="prev" title="The BitArray class" href="bitarray.html" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--[if lt IE 9]>
<script type="text/javascript" src="_static/css3-mediaqueries.js"></script>
<![endif]-->
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="bitstream.html" title="The BitStream class"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="bitarray.html" title="The BitArray class"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">bitstring</a> »</li>
<li class="nav-item nav-item-1"><a href="reference.html" accesskey="U">Reference</a> »</li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/bitstring_logo_small.png" alt="Logo"/>
</a></p>
<h4>Previous topic</h4>
<p class="topless"><a href="bitarray.html"
title="previous chapter">The BitArray class</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="bitstream.html"
title="next chapter">The BitStream class</a></p>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="the-constbitstream-class">
<h1>The ConstBitStream class<a class="headerlink" href="#the-constbitstream-class" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="bitstring.ConstBitStream">
<em class="property">class </em><code class="descclassname">bitstring.</code><code class="descname">ConstBitStream</code><span class="sig-paren">(</span><span class="optional">[</span><em>auto</em>, <em>length</em>, <em>offset</em>, <em>**kwargs</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#bitstring.ConstBitStream" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="constbitarray.html#bitstring.Bits" title="bitstring.Bits"><code class="xref py py-class docutils literal"><span class="pre">Bits</span></code></a> class is the base class for <a class="reference internal" href="#bitstring.ConstBitStream" title="bitstring.ConstBitStream"><code class="xref py py-class docutils literal"><span class="pre">ConstBitStream</span></code></a> and so all of its methods are also available for <a class="reference internal" href="#bitstring.ConstBitStream" title="bitstring.ConstBitStream"><code class="xref py py-class docutils literal"><span class="pre">ConstBitStream</span></code></a> objects. The initialiser is also the same as for <a class="reference internal" href="constbitarray.html#bitstring.Bits" title="bitstring.Bits"><code class="xref py py-class docutils literal"><span class="pre">Bits</span></code></a> and so won’t be repeated here.</p>
<p>A <a class="reference internal" href="#bitstring.ConstBitStream" title="bitstring.ConstBitStream"><code class="xref py py-class docutils literal"><span class="pre">ConstBitStream</span></code></a> is a <a class="reference internal" href="constbitarray.html#bitstring.Bits" title="bitstring.Bits"><code class="xref py py-class docutils literal"><span class="pre">Bits</span></code></a> with added methods and properties that allow it to be parsed as a stream of bits.</p>
<dl class="method">
<dt id="bitstring.ConstBitStream.bytealign">
<code class="descname">bytealign</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bitstring.ConstBitStream.bytealign" title="Permalink to this definition">¶</a></dt>
<dd><p>Aligns to the start of the next byte (so that <a class="reference internal" href="#bitstring.ConstBitStream.pos" title="bitstring.ConstBitStream.pos"><code class="xref py py-attr docutils literal"><span class="pre">pos</span></code></a> is a multiple of 8) and returns the number of bits skipped.</p>
<p>If the current position is already byte aligned then it is unchanged.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">ConstBitStream</span><span class="p">(</span><span class="s1">'0xabcdef'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">pos</span> <span class="o">+=</span> <span class="mi">3</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">bytealign</span><span class="p">()</span>
<span class="go">5</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">pos</span>
<span class="go">8</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="bitstring.ConstBitStream.peek">
<code class="descname">peek</code><span class="sig-paren">(</span><em>fmt</em><span class="sig-paren">)</span><a class="headerlink" href="#bitstring.ConstBitStream.peek" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads from the current bit position <a class="reference internal" href="#bitstring.ConstBitStream.pos" title="bitstring.ConstBitStream.pos"><code class="xref py py-attr docutils literal"><span class="pre">pos</span></code></a> in the bitstring according to the <em>fmt</em> string or integer and returns the result.</p>
<p>The bit position is unchanged.</p>
<p>For information on the format string see the entry for the <a class="reference internal" href="#bitstring.ConstBitStream.read" title="bitstring.ConstBitStream.read"><code class="xref py py-meth docutils literal"><span class="pre">read</span></code></a> method.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">ConstBitStream</span><span class="p">(</span><span class="s1">'0x123456'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">peek</span><span class="p">(</span><span class="mi">16</span><span class="p">)</span>
<span class="go">ConstBitStream('0x1234')</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">peek</span><span class="p">(</span><span class="s1">'hex:8'</span><span class="p">)</span>
<span class="go">'12'</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="bitstring.ConstBitStream.peeklist">
<code class="descname">peeklist</code><span class="sig-paren">(</span><em>fmt</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#bitstring.ConstBitStream.peeklist" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads from current bit position <a class="reference internal" href="#bitstring.ConstBitStream.pos" title="bitstring.ConstBitStream.pos"><code class="xref py py-attr docutils literal"><span class="pre">pos</span></code></a> in the bitstring according to the <em>fmt</em> string or iterable and returns a list of results.</p>
<p>A dictionary or keyword arguments can also be provided. These will replace length identifiers in the format string. The position is not advanced to after the read items.</p>
<p>See the entries for <a class="reference internal" href="#bitstring.ConstBitStream.read" title="bitstring.ConstBitStream.read"><code class="xref py py-meth docutils literal"><span class="pre">read</span></code></a> and <a class="reference internal" href="#bitstring.ConstBitStream.readlist" title="bitstring.ConstBitStream.readlist"><code class="xref py py-meth docutils literal"><span class="pre">readlist</span></code></a> for more information.</p>
</dd></dl>
<dl class="method">
<dt id="bitstring.ConstBitStream.read">
<code class="descname">read</code><span class="sig-paren">(</span><em>fmt</em><span class="sig-paren">)</span><a class="headerlink" href="#bitstring.ConstBitStream.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads from current bit position <a class="reference internal" href="#bitstring.ConstBitStream.pos" title="bitstring.ConstBitStream.pos"><code class="xref py py-attr docutils literal"><span class="pre">pos</span></code></a> in the bitstring according the the format string and returns a single result. If not enough bits are available then a <a class="reference internal" href="functions.html#bitstring.ReadError" title="bitstring.ReadError"><code class="xref py py-exc docutils literal"><span class="pre">ReadError</span></code></a> is raised.</p>
<p><em>fmt</em> is either a token string that describes how to interpret the next bits in the bitstring or an integer. If it’s an integer then that number of bits will be read, and returned as a new bitstring. Otherwise the tokens are:</p>
<table border="1" class="docutils">
<colgroup>
<col width="22%" />
<col width="78%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">int:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a signed integer.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">uint:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as an unsigned integer.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">float:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a floating point number.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">intbe:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a big-endian signed integer.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">uintbe:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a big-endian unsigned integer.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">floatbe:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a big-endian float.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">intle:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a little-endian signed int.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">uintle:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a little-endian unsigned int.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">floatle:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a little-endian float.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">intne:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a native-endian signed int.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">uintne:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a native-endian unsigned int.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">floatne:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a native-endian float.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">hex:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a hexadecimal string.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">oct:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as an octal string.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">bin:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a binary string.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">ue</span></code></td>
<td>next bits as an unsigned exp-Golomb.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">se</span></code></td>
<td>next bits as a signed exp-Golomb.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">uie</span></code></td>
<td>next bits as an interleaved unsigned exp-Golomb.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">sie</span></code></td>
<td>next bits as an interleaved signed exp-Golomb.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">bits:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bits as a new bitstring.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">bytes:n</span></code></td>
<td><code class="docutils literal"><span class="pre">n</span></code> bytes as <code class="docutils literal"><span class="pre">bytes</span></code> object.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">bool</span></code></td>
<td>next bit as a boolean (True or False).</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">pad:n</span></code></td>
<td>next <code class="docutils literal"><span class="pre">n</span></code> bits will be skipped.</td>
</tr>
</tbody>
</table>
<p>For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">ConstBitStream</span><span class="p">(</span><span class="s1">'0x23ef55302'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">'hex:12'</span><span class="p">)</span>
<span class="go">'23e'</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">'bin:4'</span><span class="p">)</span>
<span class="go">'1111'</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">'uint:5'</span><span class="p">)</span>
<span class="go">10</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">'bits:4'</span><span class="p">)</span>
<span class="go">ConstBitStream('0xa')</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#bitstring.ConstBitStream.read" title="bitstring.ConstBitStream.read"><code class="xref py py-meth docutils literal"><span class="pre">read</span></code></a> method is useful for reading exponential-Golomb codes.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">ConstBitStream</span><span class="p">(</span><span class="s1">'se=-9, ue=4'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">'se'</span><span class="p">)</span>
<span class="go">-9</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">'ue'</span><span class="p">)</span>
<span class="go">4</span>
</pre></div>
</div>
<p>The <code class="docutils literal"><span class="pre">pad</span></code> token is not very useful when used in <a class="reference internal" href="#bitstring.ConstBitStream.read" title="bitstring.ConstBitStream.read"><code class="xref py py-meth docutils literal"><span class="pre">read</span></code></a> as it just skips a number of bits and returns <code class="docutils literal"><span class="pre">None</span></code>. However when used within <a class="reference internal" href="#bitstring.ConstBitStream.readlist" title="bitstring.ConstBitStream.readlist"><code class="xref py py-meth docutils literal"><span class="pre">readlist</span></code></a> or <a class="reference internal" href="constbitarray.html#bitstring.Bits.unpack" title="bitstring.Bits.unpack"><code class="xref py py-meth docutils literal"><span class="pre">unpack</span></code></a> it allows unimportant part of the bitstring to be simply ignored.</p>
</dd></dl>
<dl class="method">
<dt id="bitstring.ConstBitStream.readlist">
<code class="descname">readlist</code><span class="sig-paren">(</span><em>fmt</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#bitstring.ConstBitStream.readlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads from current bit position <a class="reference internal" href="#bitstring.ConstBitStream.pos" title="bitstring.ConstBitStream.pos"><code class="xref py py-attr docutils literal"><span class="pre">pos</span></code></a> in the bitstring according to the <em>fmt</em> string or iterable and returns a list of results. If not enough bits are available then a <a class="reference internal" href="functions.html#bitstring.ReadError" title="bitstring.ReadError"><code class="xref py py-exc docutils literal"><span class="pre">ReadError</span></code></a> is raised.</p>
<p>A dictionary or keyword arguments can also be provided. These will replace length identifiers in the format string. The position is advanced to after the read items.</p>
<p>See the entry for <a class="reference internal" href="#bitstring.ConstBitStream.read" title="bitstring.ConstBitStream.read"><code class="xref py py-meth docutils literal"><span class="pre">read</span></code></a> for information on the format strings.</p>
<p>For multiple items you can separate using commas or given multiple parameters:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">ConstBitStream</span><span class="p">(</span><span class="s1">'0x43fe01ff21'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">readlist</span><span class="p">(</span><span class="s1">'hex:8, uint:6'</span><span class="p">)</span>
<span class="go">['43', 63]</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">readlist</span><span class="p">([</span><span class="s1">'bin:3'</span><span class="p">,</span> <span class="s1">'intle:16'</span><span class="p">])</span>
<span class="go">['100', -509]</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">pos</span> <span class="o">=</span> <span class="mi">0</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">readlist</span><span class="p">(</span><span class="s1">'hex:b, uint:d'</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mi">8</span><span class="p">,</span> <span class="n">d</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
<span class="go">['43', 63]</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="bitstring.ConstBitStream.readto">
<code class="descname">readto</code><span class="sig-paren">(</span><em>bs</em>, <em>bytealigned</em><span class="sig-paren">)</span><a class="headerlink" href="#bitstring.ConstBitStream.readto" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads up to and including the next occurrence of the bitstring <em>bs</em> and returns the results. If <em>bytealigned</em> is <cite>True</cite> it will look for the bitstring starting only at whole-byte positions.</p>
<p>Raises a <a class="reference internal" href="functions.html#bitstring.ReadError" title="bitstring.ReadError"><code class="xref py py-exc docutils literal"><span class="pre">ReadError</span></code></a> if <em>bs</em> is not found, and <code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code> if <em>bs</em> is empty.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">ConstBitStream</span><span class="p">(</span><span class="s1">'0x47000102034704050647'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">readto</span><span class="p">(</span><span class="s1">'0x47'</span><span class="p">,</span> <span class="n">bytealigned</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">BitStream('0x47')</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">readto</span><span class="p">(</span><span class="s1">'0x47'</span><span class="p">,</span> <span class="n">bytealigned</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">BitStream('0x0001020347')</span>
<span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">readto</span><span class="p">(</span><span class="s1">'0x47'</span><span class="p">,</span> <span class="n">bytealigned</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">BitStream('0x04050647')</span>
</pre></div>
</div>
</dd></dl>
<dl class="attribute">
<dt id="bitstring.ConstBitStream.bytepos">
<code class="descname">bytepos</code><a class="headerlink" href="#bitstring.ConstBitStream.bytepos" title="Permalink to this definition">¶</a></dt>
<dd><p>Property for setting and getting the current byte position in the bitstring.</p>
<p>When used as a getter will raise a <a class="reference internal" href="functions.html#bitstring.ByteAlignError" title="bitstring.ByteAlignError"><code class="xref py py-exc docutils literal"><span class="pre">ByteAlignError</span></code></a> if the current position in not byte aligned.</p>
</dd></dl>
<dl class="attribute">
<dt id="bitstring.ConstBitStream.pos">
<code class="descname">pos</code><a class="headerlink" href="#bitstring.ConstBitStream.pos" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="bitstring.ConstBitStream.bitpos">
<code class="descname">bitpos</code><a class="headerlink" href="#bitstring.ConstBitStream.bitpos" title="Permalink to this definition">¶</a></dt>
<dd><p>Read and write property for setting and getting the current bit position in the bitstring. Can be set to any value from <code class="docutils literal"><span class="pre">0</span></code> to <code class="xref py py-attr docutils literal"><span class="pre">len</span></code>.</p>
<p>The <a class="reference internal" href="#bitstring.ConstBitStream.pos" title="bitstring.ConstBitStream.pos"><code class="xref py py-attr docutils literal"><span class="pre">pos</span></code></a> and <a class="reference internal" href="#bitstring.ConstBitStream.bitpos" title="bitstring.ConstBitStream.bitpos"><code class="xref py py-attr docutils literal"><span class="pre">bitpos</span></code></a> properties are exactly equivalent - you can use whichever you prefer.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">s</span><span class="o">.</span><span class="n">pos</span> <span class="o"><</span> <span class="mi">100</span><span class="p">:</span>
<span class="n">s</span><span class="o">.</span><span class="n">pos</span> <span class="o">+=</span> <span class="mi">10</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="bitstream.html" title="The BitStream class"
>next</a> |</li>
<li class="right" >
<a href="bitarray.html" title="The BitArray class"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">bitstring</a> »</li>
<li class="nav-item nav-item-1"><a href="reference.html" >Reference</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
</div>
</body>
</html>
|