title: How to avoid "unnecessary" indentation in long class definitions?
body: <p>In both Perl and C++ 
  one has an option to write class method definitions by defining the
  method outside the class and thereby avoiding en extra level of
  indentation.</p>
  
  <p>Of course those language are
  free form (in contrast to Python) so you do not strictly need to add indentation for each
  nesting level, but one usually does so for readability. </p>
  
  <p>For example, in C++ the following class definition (approach #1):</p>
  
  <pre><code>class X {
      void x_method(int a, int b) {
          // implementation details follows here.. Note: extra indentation
      }
  };
  </code></pre>
  
  <p>can also be written with the method definition outside the class (approach #2):</p>
  
  <pre><code>class X { 
      void x_method(int a, int b);
  };
  void X::x_method(int a, int b) {
      // implementation details follows here
  }
  </code></pre>
  
  <p>In Perl, you could write the first version as:</p>
  
  <pre><code>package X {
      sub x_method {
          my ($a, $b) = @_;
          # implementation details follows here
      }
  }
  </code></pre>
  
  <p>and you can avoid the extra indentation for the method definition by using this style:</p>
  
  <pre><code>package X; 
  sub x_method {
      my ($a, $b) = @_;
      # implementation details follows here
  }
  package Y; # marks the start of another class
  # ...
  </code></pre>
  
  <p>In these
  examples I used a small class definition that extends less than the
  amount of lines that can be viewed on a computer screen (let's say
  less than 50 lines). For such definitions, approach 1 with the method
  inside the class is fine. However, once the class definition becomes
  hundreds of lines, I would prefer approach #2 by defining the class
  methods outside the class.</p>
  
  <p>However, I cannot find this approach in Python. How can I do appraoch
   #2 in Python?</p>
  
  <p>It seems to me
  that you only have approach #1 in Python:</p>
  
  <pre><code>class X:
      def x_method(a, b):
           //implementation details follows here
  </code></pre>
  
  <p>I would like to have something similar to this (approach #2):</p>
  
  <pre><code>class X:  
  def x_method(a, b):
      # implementation details..
  
  class Y:  # marks the start of another class
  # ...
  </code></pre>
  
  <p>When the number of methods (and lines) in a class definition
   increases, I think appraoch #1 becomes more and more verbose.
  Then, the only purpose I can see that the extra space (indentation) has, is
  to indicate that a method belongs to a given class X. 
  And that information (that a method belongs to a given class), does not
  need to expand and propagate over more and more lines as class
  definition grows. It is quite sufficient to contain that information to a
   single line as in Perl (using the package statement), or to a single prefix word as
   in C++ using the namespace resulution prefix operator on the method
   name in the first line of its definition.</p>
  
  <p>I am not so familiar with Python, and coming from these other lanuages
  it feels like I am suffocating in redundant space (using approach #1)
  for large class definitions, and it distracts me from my programming
  tasks. What am I missing here?</p>
  
  <p>Extra indentation also forces you to break more lines to keep within
  the recommended 80 characters per line limit.</p>