title: Python: Lambda function as a namedtuple object?
body: <p>I've written a program in which I have a fairly typical class. In this class I create multiple namedtuple objects. The namedtuple objects hold many items, which all work fine, except for lambda functions that I try to bind to it. Below is a stripped down example and the error message that I am receiving. Hope someone knows why this is going wrong. Thanks in advance!</p>
  
  <p><strong>FILE: test.py</strong></p>
  
  <pre><code>from equations import *
  from collections import namedtuple
  
  class Test:
      def __init__(self, nr):
          self.obj = self.create(nr)
          print self.obj.name
          print self.obj.f1(2)
  
      def create(self, nr):
          obj = namedtuple("struct", "name f1 f2")
          obj.name = str(nr)  
          (obj.f1, obj.f2) = get_func(nr)
          return obj
  
  test = Test(1)
  </code></pre>
  
  <p><strong>FILE: equations.py</strong></p>
  
  <pre><code>def get_func(nr):
      return (lambda x: test1(x), lambda x: test2(x))
  
  def test1(x):
      return (x/1)
  
  def test2(x):
      return (x/2)
  </code></pre>
  
  <p><strong>ERROR:</strong></p>
  
  <pre><code>Traceback (most recent call last):
  File "test.py", line 17, in &lt;module&gt;
      test = Test(1)
    File "test.py", line 8, in __init__
      print self.obj.f1(2)
  TypeError: unbound method &lt;lambda&gt;() must be called with struct instance as first argument (got int instance instead)`
  </code></pre>