(For people who fail to find any mention of protocols in PEP 634, Protocols (PEP 544) can be used (with the @runtime decorator) to override isinstance(), and class patterns are defined to use isinstance() for the class check.)
On Wed, Nov 18, 2020 at 11:50 AM Brett Cannon <br...@python.org> wrote: > > > On Wed, Nov 18, 2020 at 1:25 AM Robin Becker <ro...@reportlab.com> wrote: > >> Is there a bestiary of examples for the current pattern matching >> proposal(s)? >> >> It seems I don't have a good handle on how one matches simple tests like >> callability, > > > Doable using protocols. > > >> function signatures, > > > I don't think that's directly doable, but there might be some way to bend > it to protocols. > > >> possession of >> specific attribute(s).....etc. >> > > Protocols. > > >> >> Also will matching ever extend into the Typing universe? >> > > In what way do you have in mind? With protocol support baked into PEP 634 > that already ties into type hints. > > -Brett > > >> -- >> Robin Becker >> _______________________________________________ >> 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/OKBOTKDQ6WBEDPCBTDRYRI5HRDHRDVER/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > _______________________________________________ > 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/YMLP5QDXRCO2QJG2GXJFIG3F4F56VLPL/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ 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/42GPITT4Z7TOBYSYJ6DOMUVVBYN27MUF/ Code of Conduct: http://python.org/psf/codeofconduct/