Why is "as" not a keyword?

Paul Prescod paulp at ActiveState.com
Thu Jan 18 23:44:18 EST 2001


Jesse W wrote:
> 
> Most people know about the functionality of the import statement that
> lets you import something under a differnt name.  It uses the word "as"
> to tell the interpreter.  Why is "as" not a keyword?  Other flag parts
> of commands are keywords, like "in", or "from". Why not "as"?

As is not a keyword because the fewer keywords there are in the
language, the more flexibility you have as a programmer. You could for
instance name a variable "as" to stand for ActiveState.

> 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.  

That is merely a bug in IDLE. I wouldn't be surprised if it was fixed in
the CVS version of IDLE.

 Paul Prescod




More information about the Python-list mailing list