(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 <[email protected]> wrote: > > > On Wed, Nov 18, 2020 at 1:25 AM Robin Becker <[email protected]> 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 -- [email protected] >> To unsubscribe send an email to [email protected] >> https://mail.python.org/mailman3/lists/python-dev.python.org/ >> Message archived at >> https://mail.python.org/archives/list/[email protected]/message/OKBOTKDQ6WBEDPCBTDRYRI5HRDHRDVER/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > _______________________________________________ > Python-Dev mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/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 -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/42GPITT4Z7TOBYSYJ6DOMUVVBYN27MUF/ Code of Conduct: http://python.org/psf/codeofconduct/
