<p style="white-space: pre-wrap; word-wrap: break-word;">You don't really need 'struct' module. Let's just use to_bytes().</p><p>Patch set 1:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p><a href="https://gerrit.osmocom.org/c/pysim/+/24102">View Change</a></p><p>5 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/pysim/+/24102/1/pySim/utils.py">File pySim/utils.py:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/pysim/+/24102/1/pySim/utils.py@96">Patch Set #1, Line 96:</a> <code style="font-family:monospace,monospace">(dict, bytes)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Tuple[dict, bytes]</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/pysim/+/24102/1/pySim/utils.py@119">Patch Set #1, Line 119:</a> <code style="font-family:monospace,monospace">(int, bytes)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Tuple[int, bytes]</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/pysim/+/24102/1/pySim/utils.py@145">Patch Set #1, Line 145:</a> <code style="font-family:monospace,monospace">      if length < 0x80:</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Looks like both cases:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  length < 0x80</pre><p style="white-space: pre-wrap; word-wrap: break-word;">and</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  length <= 0xff</pre><p style="white-space: pre-wrap; word-wrap: break-word;">can be handled in one statement:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  if length <= 0xff:<br>    return length.to_bytes(1, 'big')</pre></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/pysim/+/24102/1/pySim/utils.py@150">Patch Set #1, Line 150:</a> <code style="font-family:monospace,monospace">struct.pack('!H', length)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">length.to_bytes(2, 'big')</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/pysim/+/24102/1/pySim/utils.py@152">Patch Set #1, Line 152:</a> <code style="font-family:monospace,monospace">struct.pack('!L', length)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">length.to_bytes(4, 'big')</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/24102">change 24102</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/24102"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ibfcce757dcd477fd0d6857f64fbb4346d6d62e63 </div>
<div style="display:none"> Gerrit-Change-Number: 24102 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 03 May 2021 18:07:26 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: Yes </div>
<div style="display:none"> Gerrit-MessageType: comment </div>