metaclass and customization with parameters

Carlos Ribeiro carribeiro at
Mon Oct 4 18:52:14 CEST 2004

On Mon, 4 Oct 2004 17:36:32 +0200, Alex Martelli <aleaxit at> wrote:
> Well, _this_ experienced writer keeps repeating this fact over and over
> and over again in _his_ explanations (e.g., Nutshell p. 32: "Unlike
> other languages, Python has no declarations"), but of course that
> doesn't help all that much if one's explanations just aren't read.

I can only thank you for having pointed it out to me here at this
newsgroup. I'm not fortunate enough to have a copy your books here
with me :-) But even so -- this topic _should_ be better explained,
and clarified, in the standard Python documentation. (as a side note,
it's not only declarations and metaclasses; I've read Raymond
Hettinger docs regarding descriptors, and I was left wondering why
weren't it included into the standard documentation, in some form or
> As for me, I'm leaning towards agreement with Guido, that a metaclass
> that's not a type _is_ a hack that's best avoided.  So, a 'def
> __metaclass__' is already a code smell.  A nested 'class
> __metaclass__(type):' would of course be a completely different issue,
> basically an "anonymous metaclass" so to speak, not particularly hackish
> IMHO -- for the <1% (if Tim has it right) of Pythonistas who _DO_ need
> to worry about metaclasses, of course.

During the learning process, more often than not I would try to solve
*all* problems with a metaclass, as if it was the only tool available.
Now that I'm starting to feel comfortable, things start to fall back
into the correct perspective once again. But of course, now I'm better
equiped with a powerful addition to my toolset :-) Let's not abuse it

Carlos Ribeiro
Consultoria em Projetos
mail: carribeiro at
mail: carribeiro at

More information about the Python-list mailing list