On Sat, 9 Jan 2021, 7:07 am Joseph Martinot-Lagarde, <contreba...@gmail.com> wrote:
> Paul Sokolovsky wrote: > > Hello, > > On Tue, 5 Jan 2021 20:37:27 +1000 > > Nick Coghlan ncogh...@gmail.com wrote: > > > object(host=as host, port=as port}:", but that > > > couldn't ever be > > > I'd like to point out the weirdness of the "as" syntax when applied > > to > > positional arguments, e.g.: > > case [as x, as y]: > > case Cls(as x, as y): > > That feels unnatural, and the fact behind that intuitive feeling is > > that "as" never used like that in Python so far. Where it's used > > now, there's explicit "what" is available before "as": > > import org_name as alias_name > > with expr as var: > > So again, standalone "as" feels weird. > > It's a matter of taste, I like the compacity of the standalone as. It > describe clearly the variable name, and the order matches the positional > arguments so I don't find it surprising. If it's not the positional value, > what else can it be ? What would be clearer by using an underscore, which > itself corresponds to nothing ? > The fact that it was never used like this it not an argument per se, > because that's the point of new syntax... It's also a pure syntactic shortcut, so anyone that really dislikes it could favour the "__ as name" form. The extra leading "__" doesn't convey any information that the leading "as" doesn't convey on its own, but YMMV. The key difference relative to PEP 634 is that even when the code author uses the shorthand form, *readers* will still get at least the "as" keyword as a prompt, rather than having to just know that "name" appearing in a pattern means "__ as name", unless it's a class or attribute name in a class pattern, or an attribute name in a value pattern. While we know from experience that it's feasible to keep that in mind for iterable unpacking, it's far from clear that it will work as well for the more complex destructuring involved in class and mapping patterns. Cheers, Nick. >
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/Y3XRDKT7PUQ6EZSOAXUCIAALOILHCFP3/ Code of Conduct: http://python.org/psf/codeofconduct/