Compare source code

Ethan Furman ethan at stoneleaf.us
Fri Nov 5 09:29:11 EDT 2010


Antoon Pardon wrote:
> Unless, your code is split over different pages, as when it is printed in a book.
> You also need to see the next piece of code to notice the dedention.
>
> e.g. I have the following code at the bottom of my editor.
>
>   for i := 0 to 9 do
>     some(code);
>     more(code);
>   end;
>
> I can by just looking at this code notice that I'm looking at the whole for block.
>
>
> But when I have similar python code at the bottom of the page.
>
>   for i in xrange(10):
>     some(code)
>     more(code)
>
> Then I can't make out whether I'm looking at the whole for suite or not.
These code pieces are not equivalent -- you have four lines of code in 
the first piece, only three lines in the python piece; in other words, 
if the "end;" were not on screen, you would still have no idea if it was 
the whole block or not; in still other words, the "end;", just like the 
dedented line, provides the context.

~Ethan~



More information about the Python-list mailing list