[Python-ideas] A (meta)class algebra
Andrew Barnert
abarnert at yahoo.com
Fri Feb 13 23:24:33 CET 2015
On Feb 13, 2015, at 5:27, Martin Teichmann <lkb.teichmann at gmail.com> wrote:
> Hi,
>
> me too, I missed that PEP, and yes, it would certainly work
> for all my needs.
>
> In short words, the PEP reads: forget all that metaclass stuff,
> here comes the real solution. Maybe we can even abandon
> metaclasses altogether in Python 4, I think noone would shed
> a tear over them.
>
> But if the metaclass fans should win the battle, I would like
> my proposal included sometimes.
That sounds reasonable in principle. Even if that PEP got accepted for Python 3.5, there would still be an awful lot of now-unnecessary metaclasses out there for a long time. For example, PyQt isn't going to drop 3.4 support, and, even if it did, it wouldn't be rewritten overnight. All it does is let you write a 3.5 application that works more easily with PyQt by not having to write your own metaclasses and toss them into the mix. If you still need or want to use metaclasses, you still need to mix them somehow.
But I think it also gives weight to Barry's point: the problem is that both you and PyQt are using something that's much more powerful and flexible than needed, and that forced readers of your code to think through how your metaclasses interact before they can understand your classes, and trying to sweep that under the rug may not really help beyond the "shut up and code" perspective that gets you the first 80% of the way before you have to debug something confusing and suddenly you have to figure out something very complicated when nearing a deadline...
More information about the Python-ideas
mailing list