
April 26, 2011
8:56 a.m.
On 2011-04-26, at 09:15 , Cameron Simpson wrote:
Contrived examples:
# getting the "as" name from "foo" from foo import as # but did I mean "from foo import this as that" ?
If you did, you'll realize it quite soon as you'll be missing `that` in your local namespace? In any case, the statement is not ambiguous. Not for the machine, but not for humans either.
# is this now a syntax error, since "as" is a name? with open("foo") as fp:
`as` could be used as a name, but would still be a keyword. This statement would be parsed as `with [expr] as [name]`, which is perfectly valid, why would there be a syntax error anywhere? `with open ("foo") as as` would also be valid, though one could argue less readable.