On 27/02/12 14:41, Cranky Frankie wrote:

<<A quote worth mentioning here is:  "If you need more than 3 levels
of indentation, you're screwed

I've always wondered about this quote. I'm thinking it means you might
want to have functions or subroutines, depending on the language, to
do big chunks of logic,

That's one option.

The OP also had the option of using a lookup table(dictionary)
or just using elifs instead of nested ifs.

Often a different algorithm helps.

Also functional programming (ie. not just procedural!) can reduce the numbers of indentation levels. (See the FP topic in my tutor for some examples of this.)

Simple hiding of indentation levels inside a function is kind of
the last resort in reducing indentation levels. Generally deep indentation reveals problems in the basic algorithm and/or
data structures.

offers almost unlimited indentation, so it's up to the programmer to
not use it?

Correct, this is a program design decision not a language feature.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to