[Tutor] What is the metaclass for?

Erik Price erikprice@mac.com
Fri Mar 7 08:05:04 2003


On Wednesday, March 5, 2003, at 07:10  PM, Jeff Shannon wrote:

> My short answer would be that metaclasses are a mechanism for black
> magic -- or at least, very dark grey magic. ;) Odds are good that if
> what you read about metaclasses makes no sense, then you're not likely
> to need metaclasses for anything that you're doing -- it's a very
> advanced subject for advanced programmers. (Read this as -- I don't 
> know
> just what to do with them either, so I'm sticking to what I can
> understand! ;) They're a fairly new addition to Python and I never felt
> limited by their absence. But they seem to make some people happy...)

There is a fairly popular article (among Python advocates) written by 
open source software advocate Eric Raymond where he describes a pretty 
easy-to-follow instance of using metaclasses.  Essentially he wanted a 
way to let his configuration file dynamically indicate which methods 
should be called on his classes (he was writing a program that parses a 
configuration file to make it easier for people to run a mail transfer 
agent program called "fetchmail").

http://www.linuxjournal.com/article.php?sid=3882

He describes metaclass programming about a third of the way through the 
article.


Erik





-- 
Erik Price

email: erikprice@mac.com
jabber: erikprice@jabber.org