<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 23, 2015 at 8:20 AM, Burton, Ross <span dir="ltr">&lt;<a href="mailto:ross.burton@intel.com" target="_blank">ross.burton@intel.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_extra"><span><div class="gmail_quote">On 23 October 2015 at 11:38, Peter Kjellerstedt <span dir="ltr">&lt;<a href="mailto:peter.kjellerstedt@axis.com" target="_blank">peter.kjellerstedt@axis.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="overflow:hidden">-                        field = line.rstrip().split(&quot;:&quot;)<br>
+                        # Make sure there always are at least seven elements in<br>
+                        # the field list. This allows for leaving out trailing<br>
+                        # colons in the passwd file.<br>
+                        line = line.rstrip() + &quot;::::::&quot;<br>
+                        field = line.split(&quot;:&quot;)</div></blockquote></div><br></span>It&#39;s a stylist thing but I prefer padding the field list instead of manipulating the input string. Something like</div><div class="gmail_extra"><br></div><div class="gmail_extra">  field = line.strip().split(&quot;:&quot;)</div><div class="gmail_extra">  field += [&#39;&#39;] * (7 - len(field))</div></blockquote></div><br clear="all"><div>Agreed, but I think this is cleaner:</div><div><br></div><div><div>def iter_extend(iterable, length, obj=None):</div><div>    &quot;&quot;&quot;Ensure that iterable is the specified length by extending with obj&quot;&quot;&quot;</div><div>    return itertools.islice(itertools.chain(iterable, itertools.repeat(obj)), length)</div></div><div><br></div><div>fields = iter_extend(line.rstrip().split(&quot;:&quot;), 7)</div>-- <br><div>Christopher Larson<br>clarson at kergoth dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Maintainer - Tslib<br>Senior Software Engineer, Mentor Graphics</div>
</div></div>