[Tutor] trouble with indents

Daniel McQuay simplebob at gmail.com
Mon May 28 20:44:48 CEST 2007

I would recomend you take a look at Alan Gauld's tutor. That is what got me
started and I was able to catch on fairly quick even with little to no
programming experience.


On 5/28/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "adam urbas" <adamurbas at hotmail.com> wrote in
> >  I'm not sure when to indent.  I understand that it has to be done.
> Ok, But you need to understand *why* it has to be done.
> To do that you need to understand the basic constructs
> of programming: sequences, branches, loops and modules.
> (these are described in the concepts section of my tutorial)
> Basically each construct is defined by indenting in python.
> Thus if you have a loop in your code the set of instructions
> to be repeated is indented. This makes it visually clear what
> gets repeated. More importantly it tells the Python interpreter
> what it should repeat!
> Thus, simplistically, you need to indent anything following
> a colon.
> That is after a branch instruction:  if/elif/else
> or a loop: for/while
> or a function(module) definition: def
> or inside a class: class
> The next trick is to determine when to stop indenting and
> that's actually harder to describe! Its basically when you
> want Python to stop treating your code as special - eg no
> longer part of the code to be repeated in a loop.
> > I need somewhere to start from the beginning.
> There are several non-programmers tutorials
> (including mine :-). Try one of them.
> http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
> Dive Into python is an excellent book for experienced
> programmers or after you have gone through one of those
> listed above.
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Daniel McQuay
Linux Padawan
H: 814.825.0847
M: 814-341-9013
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070528/89aaaa16/attachment.htm 

More information about the Tutor mailing list