Speaking of evil, another evil idea would be to write code that modifies the ast and changes @ between functions to call a compose function instead.
On Sun, May 24, 2020, 18:21 Steven D'Aprano <st...@pearwood.info> wrote: > On Sun, May 24, 2020 at 10:49:45AM -0400, David Mertz wrote: > > > But how would you go about getting a .__matmul__ attribute onto all > > functions. For ones you write yourselves, you could decorate them at > > definition. What about all the other functions though. > > As a functional programming fan, you might not know about this, but we > object oriented programming people have this concept called > "inheritance" where we would add the attribute to FunctionType once, and > just like magic every function would support it! > > *wink* > > Steven > (the evil twin) > > P.S. sadly, operator dunders are looked up on the class, not the > instance, so adding a `__matmul__` method to individual functions > doesn't help. It would have to be done at the class. > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/7SZBKY5JJBQ3SOQIUQO2NUKKCS3BRF4J/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/P4RSSFL2TNNWCQMPRDJALEZYTHCOOIJL/ Code of Conduct: http://python.org/psf/codeofconduct/