[Python-Dev] Re: dict.setdefault() (Patch#101102)

Tim Peters tim_one@email.msn.com
Wed, 9 Aug 2000 03:15:02 -0400


[Tim]
>> for-that-matter-i'm-a-fan-of-"from-m-import-x-as-y"-too-ly y'rs  - tim

[Guido]
> Hm.  Predictably, I'm worried about adding 'as' as a reserved word.

But it doesn't need to be, right?  That is, change the stuff following
'import' in

    'from' dotted_name 'import' ('*' | NAME (',' NAME)*)

to

    ('*' | NAME [NAME NAME] (',' NAME [NAME NAME])*)

and verify that whenever the 3-NAME form triggers that the middle of the
NAMEs is exactly "as".  The grammar in the Reference Manual can still
advertise it as a syntactic constraint; if a particular implementation
happens to need to treat it as a semantic constraint due to parser
limitations (and CPython specifically would), the user will never know it.

It doesn't interfere with using "as" a regular NAME elsewhere.  Anyone
pointing out that the line

    from as import as as as

would then be legal will be shot.  Fortran had no reserved words of any
kind, and nobody abused that in practice.  Users may be idiots, but they're
not infants <wink>.