Python: functions returned by itemgetter() not working as expected in classes
<p>The <a href="http://docs.python.org/library/operator.html#operator.itemgetter" rel="nofollow">operator.itemgetter()</a> function works like this:</p>

<pre><code>&gt;&gt;&gt; import operator
&gt;&gt;&gt; getseconditem = operator.itemgetter(1)
&gt;&gt;&gt; ls = ['a', 'b', 'c', 'd']
&gt;&gt;&gt; getseconditem(ls) 
'b'
</code></pre>

<p><strong>EDIT I've added this portion to highlight the inconsitency</strong></p>

<pre><code>&gt;&gt;&gt; def myitemgetter(item):
...     def g(obj):
...         return obj[item]
...     return g
&gt;&gt;&gt; mygetseconditem = myitemgetter(1)
</code></pre>

<p>Now, I have this class</p>

<pre><code>&gt;&gt;&gt; class Items(object):
...     second = getseconditem
...     mysecond = mygetseconditem
...
...     def __init__(self, *items):
...         self.items = items
...
...     def __getitem__(self, i):
...         return self.items[i]
</code></pre>

<p>Accessing the second item with its index works</p>

<pre><code>&gt;&gt;&gt; obj = Items('a', 'b', 'c', 'd')
&gt;&gt;&gt; obj[1] 
&gt;&gt;&gt; 'b'
</code></pre>

<p>And so does accessing it via the <code>mysecond</code> method</p>

<pre><code>&gt;&gt;&gt; obj.mysecond()
'b'
</code></pre>

<p>But for some reason, using the <code>second()</code> method raises an exception </p>

<pre><code>&gt;&gt;&gt; obj.second()
TypeError: itemgetter expected 1 arguments, got 0
</code></pre>

<p>What gives?</p>
