[Tutor] What is the metaclass for?

Jeff Shannon jeff@ccvcorp.com
Wed Mar 5 19:22:02 2003


pan wrote:

> Hi all,
>
> I've been reading something about metaclass but most of the
> documents I read so far are more or less like Martian codes to
> me. Especially, they didn't give me an idea for why we need to
> use a metaclass.
>
> Can someone describe under what a metaclass is for and under
> circumstances do we need to consider using them? 


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...)

Jeff Shannon
Technician/Programmer
Credit International