On Tue, Oct 20, 2020 at 11:26 AM Steven D'Aprano firstname.lastname@example.org 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 the actual intent is for the value to be unused -- since it is entirely impossible to use it.
is actually an anti-feature, in my opinion.
I think that people might like the idea of not actually binding a value in situations like this:
a, *?, b = expression
until you end up with something unexpected in a and b and need to debug what it going on, either in a debugger or with print:
a, *?, b = expression print(?) # wait this doesn't work;
I'm not sure how this is different than, say,
a, _, _ = range(3) print(_)
a = range(3) print(<whatever the second value is>)
That is to say, some things are impossible; if you want to print the value, don't assign to '?'.
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 strikes me as being an attractive nuisance.
And yet that's exactly what is being proposed in pattern matching. https://www.python.org/dev/peps/pep-0634/#id3
-- Steve _______________________________________________ Python-Dev mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://email@example.com/message/OPUUJWBC... Code of Conduct: http://python.org/psf/codeofconduct/