Question about Python-Grammar

Roman Meisl roman at syxx.de
Mon Jun 16 08:43:09 EDT 2003


Hello NG,

The actual Python Grammar defines following rules:

import_stmt: 'import' dotted_as_name (',' dotted_as_name)* | 'from'
    dotted_name 'import' ('*' | import_as_name (',' import_as_name)*)
import_as_name: NAME [NAME NAME]
dotted_as_name: dotted_name [NAME NAME]
dotted_name: NAME ('.' NAME)*

To simplify my question let's take following rules

import_stmt: 'import' dotted_as_name 
dotted_as_name: dotted_name [NAME NAME]
dotted_name: NAME ('.' NAME)*

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" )

I'm sure that the meaning should be different from 
import NAME, NAME, NAME

Thanks in advance!

Bye
   Roman Meisl




More information about the Python-list mailing list