[Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)
neatnate at gmail.com
Sun Apr 15 02:01:28 EDT 2018
On Sat, Apr 14, 2018 at 11:54 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, Apr 15, 2018 at 1:08 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> > === Target first, 'from' keyword ===
> > while (value from read_next_item()) is not None: # New
> > ...
> > Pros:
> > * avoids the syntactic ambiguity of "as"
> > * being target first provides an obvious distinction from the "as"
> > * typically reads nicely as pseudocode
> > * "from" is already associated with a namebinding operation ("from
> > module import name")
> > Cons:
> > * I'm sure we'll think of some more, but all I have so far is that
> > the association with name binding is relatively weak and would need to
> > be learned
> Cons: Syntactic ambiguity with "raise exc from otherexc", probably not
To me, "from" strongly suggests that an element is being obtained from a
container/collection of elements. This is how I conceptualize "from module
import name": "name" refers to an object INSIDE the module, not the module
itself. If I saw
if (match from pattern.search(data)) is not None:
I would guess that it is equivalent to
m = next(pattern.search(data))
if m is not None:
i.e. that the target is bound to the next item from an iterable (the
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas