Metaclasses vs. standard Python reflection?
Ian Bicking
ianb at colorstudy.com
Fri May 2 05:07:01 EDT 2003
On Fri, 2003-05-02 at 03:43, Jack Diederich wrote:
> metaclasses are like that while or for loop, you can work around their absence
> but it is nice not to have to. metaclasses make some hard things easier and
> less error prone. There are a number of ways to get the same effect, but none
> as tidy. Other languages solve the same problem with code generation tools[1]
Indeed, people *do* sometimes do code generation in Python, and it would
be better to change that to metaclasses. There's several database
persistence tools that do this, and I believe a tool for creating Python
objects out of a XML DTD also uses code generation.
>From what I can tell about aspect-oriented programming (about which I am
still fuzzy), database and XML wrappers are good candidates for AO
techniques, and a specific metaclass can implement many of the ideas
behind AO (though maybe coming from a slightly different angle). But at
the moment I only have a vague intuition about what problems are
appropriate for AO programming, ditto metaclasses.
Ian
More information about the Python-list
mailing list