Python Grammar (was Re: A TYPICAL NEWBIE MISTAKE?)

Dirck Blaskey dirck.IsGettingTooMuchSpam at pacbell.net
Tue May 16 10:22:53 CEST 2000


Moshe Zadka <moshez at math.huji.ac.il> wrote in message
news:Pine.GSO.4.10.10005150709541.25548-100000 at sundial...
> On Mon, 15 May 2000, Courageous wrote:
>
> > I miss the colons all the time, too (as Mr. Pinard so
> > readily pointed out.... ha). Which brings me to the topic.
> > Sometimes colons seem syntactically unnecessary.

Hmm, I remember a thread like this recently :-)

> Theoretically, a colon is only necessary in things like
>
> if yes: print "yes"

Oddly enough, the parser doesn't really need the colon here either.
It can manage to figure out where the if expression ends without it.

The colon is almost entirely for readability purposes.
(there are a couple of places where ambiguity occurs without it).

If you're curious about the other thread,
or about Python without colons,
or to test my above assertion,
check out:

http://www.danbala.com/python/colopt

BTW
With some minor tweaks to my editor config,
and a little more consistent practice,
I'm having less trouble with the colon's now...
but I still forget them occasionally.

d

===========================
Dirck Blaskey
Danbala Software
http://www.danbala.com






More information about the Python-list mailing list