On Tue, Jun 23, 2020 at 10:59 PM Rob Cliffe via Python-Dev <
python-dev@python.org> wrote:

>
> >> I also (with others) prefer `else:` or perhaps `case else:` to using
> >> the`_` variable.
> >> The latter is obscure, and woudn't sit well with code that already
> >> uses that variable for its own purposes.
> >>
> > I think that's done for consistency. '_' is a wildcard and you can have:
> >
> >     case (_, _):
> >
> > to match any 2-tuple, so:
> >
> >     case _:
> >
> > would match any value, and can thus already serve as the default.
> >
> Consistency with what?  Where else is `_` currently used as a wildcard?


Calling it a wildcard for the purposes of matching is more about using the
terminology someone who wants to match a thing would search for. In other
contexts it's called a throwaway, but it serves the exact same purpose.
Calling it a throwaway would confuse people who don't know how language
features are linked, but just know they want a catchall/wildcard.

I wonder if it's time to officially designate _ as a reserved name.
_______________________________________________
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/QIRPBTPDQGMMYS26OB6JUTB2NN42OXBQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to