IndentationError: two many levels of indentation

Martin v. Löwis martin at v.loewis.de
Fri Mar 7 09:17:51 CET 2003


Two Inches <missedby2inches at gmx.net> writes:

> We've got this error when we tried to execute code that was created
> with a generator tool. The code had about 500 levels of indentation
> (nested if blocks). It is no problem for us to change the generator.
> 
> However, I couldn't find this limitation in the language
> reference. Shouldn't it be in there? What is the exact limit?
> 
> Is there any technical rational for this limit?

There is no limit in the compiler that I know of. Instead,
IndentationError indicates a genuine error in your Python code. It is,
for example, generated if you write


   print x
      print y

This is a IndentationError (which is a SyntaxError), as you shall not
indent the second line more than the first one.

Regards,
Martin





More information about the Python-list mailing list