<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br><br>For me, the &quot;()&quot; look like artificial, not necessary. I would prefer just to type &nbsp;&nbsp; &quot;a.list_1stpart&quot; &nbsp; , a property.<br>

<br><br><br>-- <br><br></blockquote></div>Others have explained their preference for using get methods for accessing internal data structures,&nbsp;<div>However it does look like you have specifically mentioned a preference for attribute like access:</div>
<div><br></div><div>e = ExampleList([1,2,3,4], 2)</div><div>&gt;&gt;&gt; e.firstpart</div><div>[1,2]</div><div><br></div><div>rather than</div><div>&gt;&gt;&gt; e.firstpart()</div><div>[1,2]</div><div><br></div><div>We can implement this using properties, and I will refer you to some of the documentation&nbsp;<a href="http://docs.python.org/library/functions.html#property">http://docs.python.org/library/functions.html#property</a></div>
<div><br></div><div>Here is just one way that you could simply implement a property in your case:</div><div><br></div><div>class ExampleList(object):</div><div>&nbsp;&nbsp; &quot;&quot;&quot;Note that this is a new style class.&quot;&quot;&quot;</div>
<div>&nbsp;&nbsp; def __init__(self, sequence, position):</div><div>&nbsp;&nbsp; &nbsp; &nbsp;self._sequence = sequence</div><div>&nbsp;&nbsp; &nbsp; &nbsp;self._position = position</div><div>&nbsp;&nbsp; @property</div><div>&nbsp;&nbsp; def firstpart(self):</div><div>&nbsp;&nbsp; &nbsp; &nbsp;&quot;&quot;&quot;This method will be called on inst.firstpart rather than inst.firstpart().&quot;&quot;&quot;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;return self._sequence[:self._position]</div><div><br></div><div>Here I have used property as a decorator (described in the link), now you can get your</div><div>firstpart through attribute access (not that you cannot &#39;set&#39; to it):</div>
<div>&nbsp;</div><div>e.firstpart</div><div><br></div><div>Cheers,</div><div><br></div>