On Tue, Oct 20, 2020 at 11:26 AM Steven D'Aprano <st...@pearwood.info> 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(_) or a = range(3)[0] 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 -- 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/OPUUJWBCK37CQXOYIFYSUIXFQSWTTCCA/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Thomas Wouters <tho...@python.org> Hi! I'm an email virus! Think twice before sending your email to help me spread!
_______________________________________________ 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/I7S4C7CWW2LGELO7KA2PI4SNUT6ITAZE/ Code of Conduct: http://python.org/psf/codeofconduct/