Python Rocks!

Martijn Faassen m.faassen at vet.uu.nl
Wed Jan 19 16:54:51 EST 2000


Okay, just _one_ serious post then. Sorry all to contribute to this. :)

tye4 <tye4 at yahoo.com> wrote:
[someone gives an example of C's delimiter problem]
> Perfect example.

While yours is bogus:

>    if (a > 3)
>      if (b == 4)
>         c = 2;
>     else
>      c = 3;

In actual semi-Python this example would look like this:

a, b, c = 1, 2, 3 # added to avoid NameErrors 

if a > 3:
  if b == 4:
     c = 2
 else:
  c = 3

Execute it:

inconsistent dedent
  File "test.py", line 6
    else:
        ^
SyntaxError: invalid token

> If you add a space, the 'else' will belong to the inner 'if'.

Ah, I get:

  File "test.py", line 7
    c = 3
    ^
SyntaxError: invalid syntax

> If you delete one, the 'else' will belong to the outer one.

Wow, this variety actually doesn't give a syntax errors. This is because
the indentation lines up.

> Highly error prone.

Yes, the Python interpreter doesn't like your example and complains.

Have you actually _tried_ Python? Indenting takes some getting used to,
and perhaps you're one of those people that will still dislike it after
having tried, but give it a shot first, at least?

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list