Python indentation

Alan Gauld alan.gauld at
Thu Jul 8 11:29:05 CEST 2004

On Thu, 08 Jul 2004 06:09:45 GMT, "Sateesh"
<ext-sateesh.kavuri at> wrote:
> I am just wondering, how huge if, else blocks of code can be easily handled
> in python. 

Given that modern editors typically display 50-100 lines of code
at a time its not been a big problem. Also given the much higher
level of code in Python vv C you don't get so many huge blocks.
Finally if you regularly come across blocks of code more than 50
lines long then I think its probably time to start refactoring
that code! :-)

In fact the longest indented blocks I find are class definitions.
Those can be several hundred lines long and it can be hard to
know which class you are reading if several big classes exist
inside a module. It's one area where I wish Python had adopted
the Delphi interface/implementation style where the class
interface isb published and the individuial methods are
implemented separately

class C
   def __Init__(a,b,c): pass
   def f(d): pass
   def g(): pass

implementation: <---- New keyword or something?

def C.__Init__(a,b,c)
  # initialise here

def C.f()
  # real code here

def C.g():
  # and here

But thats for another topic I guess... :-)

Alan G.
Author of the Learn to Program website

More information about the Python-list mailing list