[Python-ideas] Syntax for easy binding __name__, __module__, __qualname__ to arbitrary objects

Stephen J. Turnbull stephen at xemacs.org
Tue May 14 10:51:31 CEST 2013


Greg Ewing writes:

 > My opinion is that imposing any such restriction on
 > the use of "as" would be a foolish consistency that
 > rules out a lot of natural-sounding constructs.

Natural language is poorly fitted to be a programming language
precisely because everything is possible.  Not all natural constructs
need to be anointed as Python syntax.  It's especially important that
constructs' semantics are indicated by their syntax.  I suspect that
use of both "... NAME as EXPR" and "... EXPR as NAME" would come at a
readability cost.

We should also remember that there are lots of Python programmers to
whom none of the syntax that is natural-sounding to the English-
trained ear is particularly mnemonic.  The consistent application of a
few regular rules of formation and failure to adhere to idiomatic
variants is one important reason you can typically distinguish native
from non-native writing at a glance.  I suspect that catering to this
preference for consistency with existing simple rules will make it
easier for anybody (regardless of mother tongue) to become fluent in
Python.

Regardless the decision about use of "NAME as EXPR" syntax, I'm +1 on
Nick's explanation that the "def" keyword indicates definitive binding
of a name occurs as well as incidental (formal) binding, while its
absence means that incidental binding only occurs.  For that reason I
think the same "=" operator should be used to signify the incidental
binding.



More information about the Python-ideas mailing list