On Tue, May 17, 2016 at 11:18 AM Dirk Bächle <tshor...@gmx.de> wrote:
> > > It's not so great to require > > that the user must explicitly ``add`` their derived class after defining > > it. Perhaps that add function could be a decorator? > > Our current API doesn't use decorators at all, since it's also aimed at > people with no (or only some) knowledge of Python. I think you'll find that users of decorators do not need any special knowledge. The Flask framework (http://flask.pocoo.org/) is proof of that. > decorators...would have looked strange to the average user perhaps? > Many beginners are willing to mimic your example code without questioning what that "@" thingy is doing above the function or class. Compare that with trying to explain to a C++ user that in Python classes are actually objects and you can pass them to the ``add`` function to register them... that's going to take a while. We're now free to add them into the mix for our new Python 2.7.x/3.y > codebase, but this would probably require an API discussion > first. > An alternative would be creating a TaskmasterMeta metaclass that registers the Taskmaster subclass when it's defined. I'm a little reluctant to recommend that one. I find decorators to be more elegant. -- https://mail.python.org/mailman/listinfo/python-list