question: metaclass and C - a new general style

Jens Gelhaar cuiod-tec at web.de
Tue Nov 27 02:06:38 EST 2001


Hi,

> Martin  wrote 

> I recommend to use the existing Don Beaudry hook. If you specify a
> the class name, the base classes, and the class dictionary; its return
> value is the newly-created class.
> 
> In this hook, you can easily invoke __metainit__ yourself.

I dont like this hook for serveral reasons. When I read some postings
about the metaclass stuff and see some implementation. There is no
wonder, why so many people dont understand these matter and there for
can not use it.
   I dont like to create an class and make instance of it, to get
callable object and use it as ancestor. If you work with helper
classes, it get even more confusing. Then you have an method helper
class and so on. It is difficult to get it right in UML and if you try
to follow a debug trace you get grey hairs.
   It would be much more obvious, if you define a class with an
__metainit__ (however you call it) and you have normal inheritance AND
and way to control the inheritance. These would be sufficient for the
most cases and everyone could understand AND read the code.
   What do you thing about it?
Yesterday evening I dove in the source code and found a simple way,
just 8 lines in classobject.c

Jens



More information about the Python-list mailing list