Info needed on metaclasses / type-ing

Terry Reedy tejarex at yahoo.com
Sat Mar 23 11:11:54 EST 2002


"Dimitris Garanatsios" <rs96057 at hotmail.com> wrote in message
news:a7i109$ufh$1 at ulysses.noc.ntua.gr...
> I recently browsed through an unfinished book of Bruce Eckel,
"Thinking in
> Python", Revision 0.1.2
> I found the following peace of code there:

> class SingletonMetaClass(type):
...
> My question is about the "SingletonMetaClass" class.
> I have tried in the past to create my own types using Python and
just could
> not find a way of doing that since built-in type objects' structure
where
> not documented.
>
> The "SingletonMetaClass though", as far as i can understand, please
help me
> with that, is doing exactly what i wanted: a new type definition.

Actually, you can new derive new types from old without using the more
complex metaclass machinery.  See below.

> I browsed  Python's manuals to find more about the attributes and
functions
> that are  used, but found nothing...
...
Everything you ask about is new to Python 2.2.  Did you search *that*
manual?  Look in "What's new for Python 2.2" (or something like that)
and read the GvR essay referenced therein which is a semi-tutorial on
the new type/class stuff.

Terry J. Reedy






More information about the Python-list mailing list