On Sat, Apr 14, 2018 at 11:54 PM, Chris Angelico <ros...@gmail.com> wrote:
> On Sun, Apr 15, 2018 at 1:08 PM, Nick Coghlan <ncogh...@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
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/