Why aren't colons optional?
David C. Ullrich
ullrich at math.okstate.edu
Mon Jan 21 13:47:03 EST 2002
On Sun, 20 Jan 2002 19:11:05 GMT, "Fredrik Lundh"
<fredrik at pythonware.com> wrote:
>Hans Nowak wrote:
>
>> Note the colons in your own post. :-)
>
>People who complain about this always use colons
>correctly in their own posts,
Are you _certain_ that the first colon in
"Obviously, colons are required in:
if a == 1 : b = c
elif a == 2 : b = d
else : b = e"
is correct? I can't put my finger on exactly why
but it rubs me the wrong way - I'd think that a
colon would be appropriate if he'd said
"Obviously, colons are required in the following:"
Ah, Strunk&White "the Elements of Style" agree;
on p.7 they say "Use a colon after an independent
clause..." - the point is that "Obviously, colons
are required in" is not an independent clause,
while "Obviously, colons are required in the
following" _is_ an independent clause.
They give a few examples in case we don't follow
that: They state explicitly that
"You dedicated whittler requires: a knife, a piece
of wood, and a back porch."
is wrong and should be rewritten
"Your dedicated whittler requires three props:
a knife, a piece of wood, and a back porch."
followed by a similar example where the suggested
rewriting simply eliminates the colon.
(Now we gotta change Python from "for j in range(10):"
to "for j in range(10) do the following:")
>and they never under-
>stand arguments that ends with a smiley ;-)
That's clear.
></F>
>
>
David C. Ullrich
More information about the Python-list
mailing list