BTW, if one can come up with a pure-Python implementation for these, I'd like to take a peek at the code, please.
On 31 January 2017 at 13:57, Joao S. O. Bueno <jsbu...@python.org.br> wrote: > On 31 January 2017 at 13:05, Thomas Kluyver <tho...@kluyver.me.uk> wrote: >> On Tue, Jan 31, 2017, at 02:32 PM, Stephen J. Turnbull wrote: >>> Personally, I don't think the explicit invocation is such a big deal >>> to need a standardized decorator in the stdlib. >> >> +1. It's one line either way, and the explicit call to super() seems >> clearer for people reading the code. > > I agree that the explict call to super() is clear and concise enough > - moreover you are in full control of > where to call, plus what parameters to forward. > > BUT - no, it is _not_ an easy decorator to craft - and I don't think > it can be made to work > cleanly without depending on implementation details of cPython. > > I've been hitting the Python shell for 40+ minutes now, trying to get, > in pure Python, a way > for a method decorator to get a reference to the superclass in the way > "super" does - it is not feasible > without a metaclass. (I mean...it may be feasable, but one will be > tough - one does not have a reference > to the superclasses inside a class body as it is being parsed - I > tried to trick the Python runtime into > creating an empty __class__ cell in the decorator body for a decorator > defined outside the class, and have > that filled in, but it does not work as well). > > Still, such @pre_super and @post_super decorators might be something > cute to have around - and > can't be made in a trivial way either on the code base or on a > pure-python 3rd party package. > > I would say I am +0 to "+0.5" on them. > > > js > -><- _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/