This link has been bookmarked by 42 people . It was first bookmarked on 03 May 2008, by francois not.
-
25 Nov 14
-
Have you ever seen code like this in C or C++?
/* Warning: bogus C code! */
if (some condition)
if (another condition)
do_something(fancy);
else
this_sucks(badluck);
Either the indentation is wrong, or the program is buggy, because an "else" always applies to the nearest "if", unless you use braces. This is an essential problem in C and C++. Of course, you could resort to always use braces, no matter what, but that's tiresome and bloats the source code, and it doesn't prevent you from accidentally obfuscating the code by still having the wrong indentation. (And that's just a very simple example. In practice, C code can be much more complex.)
In Python, the above problems can never occur, because indentation levels and logical block structure are always consistent. The program always does what you expect when you look at the indentation.
-
-
20 Oct 13
-
20 Oct 12
-
04 Jan 12
-
23 Nov 11
-
30 Sep 11
-
15 Apr 11
-
21 Feb 11
-
11 Sep 10
pootzko ~d(O_o)b~There are quite some prejudices and myths about Python's indentation rules among people who don't really know Python.
python programming coding dev reference myths style indentation
-
29 Jan 10
-
12 Oct 08
-
21 May 08
-
29 Apr 08
-
21 Apr 08
-
20 Apr 08
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.