[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-21 Thread Larry Hastings
On 10/20/20 10:45 PM, Paul Sokolovsky wrote: One problem with this PEP, which I didn't see mentioned in the other replies, is that it tries to grab "?" character, which is already sought-for by another pending PEP: "PEP 505 -- None-aware operators", https://www.python.org/dev/peps/pep-0505/ .

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Paul Sokolovsky
Hello, On Tue, 20 Oct 2020 00:00:49 +0200 Thomas Wouters wrote: > One of the problems I have with the Pattern Matching proposal (PEP 622 > originally, now PEPs 634, 635, 636) is the special-casing of '_' to > not actually assign to the name, which is a subtle but meaningful > divergence from

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Steven D'Aprano
On Tue, Oct 20, 2020 at 01:41:02PM +0200, Thomas Wouters wrote: > > a, *?, b = expression > > print(?) # wait this doesn't work; > > > > I'm not sure how this is different than, say, > > a, _, _ = range(3) > print(_) For starters, that will actually print something, not fail

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Paul Moore
On Tue, 20 Oct 2020 at 14:26, Thomas Wouters wrote: > I'm not sure how to put it differently than I have in the PEP or the email: I > proposed they use ? instead of _ and also apply that to regular unpacking > (because it is very easy to see pattern matching as an extension of unpacking >

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Thomas Wouters
On Tue, Oct 20, 2020 at 2:44 PM Paul Moore wrote: > On Tue, 20 Oct 2020 at 13:25, Thomas Wouters wrote: > > > > On Tue, Oct 20, 2020 at 2:22 PM Paul Moore wrote: > >> > >> On Tue, 20 Oct 2020 at 13:13, Thomas Wouters wrote: > >> > The reason for this PEP is that pattern matching will make '_'

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Paul Moore
On Tue, 20 Oct 2020 at 13:25, Thomas Wouters wrote: > > On Tue, Oct 20, 2020 at 2:22 PM Paul Moore wrote: >> >> On Tue, 20 Oct 2020 at 13:13, Thomas Wouters wrote: >> > The reason for this PEP is that pattern matching will make '_' (but not >> > any other names) have the behaviour suggested in

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Steve Dower
On 20Oct2020 1309, Thomas Wouters wrote: The reason for this PEP is that pattern matching will make '_' (but not any other names) have the behaviour suggested in this PEP, but *only* in pattern matching. Then why is this PEP proposing a different syntax? At the very least, wait for pattern

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Thomas Wouters
On Tue, Oct 20, 2020 at 2:22 PM Paul Moore wrote: > On Tue, 20 Oct 2020 at 13:13, Thomas Wouters wrote: > > The reason for this PEP is that pattern matching will make '_' (but not > any other names) have the behaviour suggested in this PEP, but *only* in > pattern matching. > > That's something

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Paul Moore
On Tue, 20 Oct 2020 at 13:13, Thomas Wouters wrote: > The reason for this PEP is that pattern matching will make '_' (but not any > other names) have the behaviour suggested in this PEP, but *only* in pattern > matching. That's something that should be addressed or debated in the pattern

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Thomas Wouters
On Tue, Oct 20, 2020 at 2:02 PM Chris Jerdonek wrote: > On Mon, Oct 19, 2020 at 3:11 PM Thomas Wouters wrote: > >> PEP: 640 >> Title: Unused variable syntax >> Author: Thomas Wouters >> > ... > >> In Python it is somewhat common to need to do an assignment without >> actually >> needing the

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Chris Jerdonek
On Mon, Oct 19, 2020 at 3:11 PM Thomas Wouters wrote: > PEP: 640 > Title: Unused variable syntax > Author: Thomas Wouters > ... > In Python it is somewhat common to need to do an assignment without > actually > needing the result. Conventionally, people use either ``"_"`` or a name > such > as

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Steve Dower
On 20Oct2020 1021, Steven D'Aprano wrote: In my opinion, having a convention to treat certain variables as "unused" is great (I'm partial to `__` myself, to avoid clobbering the special variable `_` in the REPL). But having that be a pseudo-variable which is *actually* unused and unuseable

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Thomas Wouters
On Tue, Oct 20, 2020 at 11:26 AM Steven D'Aprano wrote: > I can't say that I like the look of pseudo-assignment to question mark: > > for ? in range(20): > ... > > but I could probably learn to live with it. But one of your > rationalisations: > > > > and makes it more obvious that >

[Python-Dev] Re: PEP 640: Unused variable syntax.

2020-10-20 Thread Steven D'Aprano
I can't say that I like the look of pseudo-assignment to question mark: for ? in range(20): ... but I could probably learn to live with it. But one of your rationalisations: > and makes it more obvious that > the actual intent is for the value to be unused -- since it is entirely