title: Is it possible to override a method in a namedtuple in Python?
body: <p>Let's say I have a class like this:</p>
  
  <pre><code>class Foo(namedtuple('Foo', ['f1'])):
      def f1(self):
          print('Default f1')
  
      def __new__(cls, f1=f1):
          return super().__new__(cls, f1)
  </code></pre>
  
  <p>And let's say I create a Foo object later on and choose to override the method definition for f1, like so:</p>
  
  <pre><code>def my_f1():
      print("My f1")
  
  foo = Foo(f1=my_f1)
  </code></pre>
  
  <p>If I then try:</p>
  
  <pre><code>foo.f1()
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>Default f1
  </code></pre>
  
  <p>I'm trying to get "My f1" to print, of course. I also want f1 to be optional. What's going on here? Is it possible to define a default implementation for a method in a namedtuple and then override it in <strong>new</strong>?</p>