[Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)
Nathan Schneider
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"
> keyword
> > * 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
> serious.
>
>
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
"container").
Cheers,
Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180415/b29557ee/attachment.html>
More information about the Python-ideas
mailing list