Hooks, aspect-oriented programming, and design by contract

Aahz Maruch aahz at panix.com
Fri Jan 25 16:07:26 EST 2002


In article <a2mcpt$rf3$1 at serv1.iunet.it>, Alex Martelli <aleax at aleax.it> wrote:
>
>I find it strange to say that a metaclass "involves class modification";
>that's the same as saying that a class "involves instance modification",
>since the class-metaclass relationship is that of instance-class too.  A
>metaclass _builds_ a class (in just the same sense as a class _builds_
>an instance), defines the class's behavior (ditto).

Just to make sure I'm getting this straight, in the past James Althoff
has talked about Smalltalk's design, and IIRC, he said that in Smalltalk
it is *instances* of metaclasses that create classes.  Can anyone
confirm or deny?  If confirmed, am I understanding correctly that in
Python, the metaclass directly instantiates a class object?

If I understand all this correctly, it would seem to me that Python's
metaclasses bear (at least in theory) the same relationship to classes
that classes have to instances, and therefore while changing the
metaclass of a class may be possible, it would only have an effect on
future usage of the class object.  There would be no effect on instances
already created by the class object unless they make use of the class
directly.

Have I gotten all this straight?

Mind you, I still have no clue what metaclasses are good for.  ;-)
-- 
                      --- Aahz  <*>  (Copyright 2002 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

"I support family values -- Addams family values" --www.nancybuttons.com



More information about the Python-list mailing list