Why is "as" not a keyword?

Jesse W jessw at loop.com
Sun Jan 21 01:45:35 EST 2001


Thank you very much, everyone!  You answered my question(s) thourghly
and (mostly) politely. ;-) This is why the python newsgroup prospers! 
Thank you.
Tim Peters wrote:
> 
> [Jesse W]
> > Why is "as" not a keyword?
> 
> Because-- and unlike "in" and "from" --it's a *recent* addition to the
> language.  Keywords are reserved words in Python:  you cannot use them for
> any other purpose.  Making "as" a keyword at this late stage would have
> broken any existing program that happened to already use "as" for its own
> purposes (vrbl name, class name, whatever).
Oh, now I understand.  Although it(making "as" a keyword) would be
neater, I see
why it would cause more problems than it would solve.
 
> > ...
> > Currently, it seems to me to be confusing when you type
> >       import foo as bar
> >  in IDLE, and import lights up as a keyword, but "as", which has to be
> > there and is clearly part of the syntax, does not.
> 
> Yup!  In 2.1 alpha 1 (due out Real Soon), I fiddled IDLE to color each word
> instance of "as", in "import ..." and "from xxx import ..." statements, and
> on the same physical line following the "import" part, as if it were a
> keyword.  This is a cheap approximation to the truth.
Ah, that should fix the confusion quite aceptably.

							Jesse W



More information about the Python-list mailing list