Question about Python-Grammar

W Isaac Carroll icarroll at pobox.com
Mon Jun 16 16:53:57 EDT 2003


Bernhard Herzog wrote:
> Roman Meisl <roman at syxx.de> writes:
>>which makes following import-statement possible:
>>import NAME NAME NAME
>>
>>What's the sense of this statement? Or is this an error in the
>>grammar?
>>
>>(Even the compiler (2.2.2) claims a syntax error when parsing 
>>"import mod1 mod2 mod3" )
> 
> But not for "import mod1 as mod2". 
> 
> The "as" in there is not a keyword and thus can't be in the Grammar
> explicitly AFAIK so constraining "import NAME NAME NAME" to cases where
> the second NAME is "as" is done by the compiler.

The basic idea here is that "as" ought to be a keyword in Python, but 
for historical reasons isn't. My understanding is that making it a 
keyword has been looked into and it would be more trouble than it's worth.

TTFN






More information about the Python-list mailing list