Hi all,
Just wanted to give a heads up (albeit late--I've been on vacation--so
apologies if this has already come up here) about PEPs 487 and 520:
https://www.python.org/dev/peps/pep-0487/
https://www.python.org/dev/peps/pep-0520/
I've been following the discussion of these PEPs for months now, and
they are finally ready and will be implemented in Python 3.6.
The scope of these PEPs relates to advanced class customizations that
occur at class-definition time. These customizations normally require
use of custom *metaclasses* in ways that are often complicated,
bewildering, and make coding more difficult. I am "guilty" of many
examples of this in Astropy :) (for good reasons, but it complicates
things all the same).
Once Python 3.6 is out I would encourage looking for bits in Astropy
that can be simplified by these PEPs. The most obvious that comes to
mind is the OrderedDescriptor class, and its associated
OrderedDescriptorContainer class (that a class must subclass in order
for OrderedDescriptors to work on it). PEP 520 makes
OrderedDescriptor trivial, and obviates the need for it.
One could certainly find other examples as well, and if anyone would
like any guidance I can point those out.
Of course, the downside to all this is that it will only be available
in Python 3.6+. So the existing implementations will have to hang
around for a long time. But I would encourage implementing version
checks: For Python < 3.6 use the existing implementation; for Python
>= 3.6 use a simpler replacement implementation.
Yay for more reasons to move to Python 3.6! I was skeptical of these
PEPs at first, because I felt that everything they do can already be
done with metaclasses if you know what you're doing, and didn't like
the idea of adding still more magic __dunder__ methods. But that's a
big "if", and this really does make a lot of *common* tasks a lot
simpler that writing yet another boilerplate metaclass. So I'm
convinced--this is a big win.
Best,
Erik B.