Metaclasses vs. standard Python reflection?
Michele Simionato
mis6 at pitt.edu
Fri May 2 09:25:23 EDT 2003
"Raymond Hettinger" <vze4rx4y at verizon.net> wrote in message news:<Qnnsa.30382$J27.8209 at nwrdny02.gnilink.net>...
> > I've been looking for examples of metaclasses I can use for a talk I'm
> > going to be giving next week, but I've been having trouble finding
> > examples that solve problems that wouldn't just as easily be via
> > Python's uber-reflective __getattr__/__setattr__ and inheritance.
> > Does anyone have a good example of a problem that's solved more
> > "beautifully" with metaclasses than with Python's standard reflection
> > facilities?
>
> The programming by contract example favors a metaclass solution.
>
>
> Raymond Hettinger
I think Raymond had in mind this example in the standard distribution:
Demo/metaclasses/Eiffel.py
There are other examples as well; I see that Python 2.3 has also
a new directory Demo/newmetaclasses; I guess the difference is that
the examples in Demo/metaclasses compile under 1.5.2
whereas the examples in Demo/newmetaclasses require 2.2+.
Michele
More information about the Python-list
mailing list