title: Ensure a class always uses its own version of a method rather than the one defined in a subclass?
body: <p>I have this code:</p>
  <pre><code>class A:
      def __init__(self, vals: list):
          self._vals = vals
  
      def __len__(self) -&gt; int:
          # some side effects like logging maybe
          return len(self._vals)
  
      def print_len(self) -&gt; None:
          # some function that uses the len above
          print(len(self))
  
  
  class B(A):
      def __len__(self) -&gt; int:
          return 0
  </code></pre>
  <p>The issue is, I want <code>print_len</code> to always call <code>A.__len__</code>. I can do this:</p>
  <pre><code>class A:
      def __init__(self, vals: list):
          self._vals = vals
  
      def __len__(self) -&gt; int:
          return len(self._vals)
  
      def print_len(self) -&gt; None:
          print(A.__len__(self))
  
  
  class B(A):
      def __len__(self) -&gt; int:
          return 0
  </code></pre>
  <p>But it feels wrong. Basically I want B to lie about <code>__len__</code> to outside callers, but internally use the correct len specified in A.</p>
  <p>So</p>
  <pre><code>a = A([1, 2, 3])
  print(len(a))  # print 3
  a.print_len()  # print 3 - no surprises there
  
  b = B([1, 2, 3])
  print(len(b))  # print 0 - overload the __len__
  b.print_len()  # want this to be 3 using A's __len__, not 0 using B's __len__
  </code></pre>
  <p>Is there any way to <strong>ensure a class always uses its own version of a method rather than a subclass' version?</strong> I thought name mangling of dunder methods would help here.</p>