On Tue, Jun 1, 2021 at 9:57 PM Steven D'Aprano <st...@pearwood.info> wrote: > > On Thu, May 27, 2021 at 12:33:20PM -0400, Ricky Teachey wrote: > > > On Thu, May 27, 2021 at 10:25 AM Steven D'Aprano <st...@pearwood.info> > > wrote: > > > > > > Okay. Without reading the source code, does this code snippet use the > > > old `__call__` protocol or the new `__decoration_call__` protocol? > > > > > > > > > @flambé > > > class Banana_Surprise: > > > pass > > > > > > > Invoking @flambé causes: > > > > flambé.__decoration_call__(Banana_Surprise, "Banana_Surprise") > > > > ...to be used, if flambé has that method. > > Right: you can't tell from the code you are looking at whether flambé is > being called as a new or old style decorator. You have to dig into the > definition of flambé to work out the meaning of the code. > > On the one hand we have the current decorator protocol, where the object > flambé is called with a single argument, the class Banana_Surprise.
My understanding is that it would attempt to invoke __detonation_call__ (err, I mean, __decoration_call__, but just think how awesome the other would be) first, and if it can't find it, it falls back on regular __call__. That would parallel how most other things are done - repr falling back to str, iadd falling back to add, etc. That said, I still don't like the idea of decorating a bare name. A magic "assignment target" token that translates into the string form of the thing being assigned to is far more useful and far less magical. ChrisA _______________________________________________ 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/NN5BVKDUHPXJCHGGM7OFTFJHEVE3GDBZ/ Code of Conduct: http://python.org/psf/codeofconduct/