CONSTRUCT - Adding Functionality to the Overall System

Damjan gdamjan at gmail.com
Sun Sep 17 17:10:35 EDT 2006


>> I understand that I can use __metaclass__ to create a class which
>> modifies the behaviour of another class.
>> 
>> How can I add this metaclass to *all* classes in the system?
>> 
>> (In ruby I would alter the "Class" class)
> 
> You'd have to set
> 
> __metaclass__ = whatever
> 
> at the top of each module whose classes are to get the new behavior.

I think '__metaclass__ = whatever' affects only the creation of classes that
would otherwise be old-style classes?
 
> You can't alter classes which you don't control or create in your code.

I remeber I've seen an implementation of import_with_metaclass somewhere on
IBM's developerworks. I didn't quite undersntad it though.



-- 
damjan



More information about the Python-list mailing list