need something like __init__ in classes __classinit__

Kevin Jacobs jacobs at darwin.epbi.cwru.edu
Sat Mar 9 10:24:19 EST 2002


Jens Gelhaar <cuiod-tec at web.de> wrote:
> I looks like a conflict between "type" and "extensionclass". 

> Beside, for me it would be natural to have a hook during "compile
> time" like __classinit__. Serveral years ago I worked with FORTH and
> there was no difference between compile and runtime. It was easy to do
> everything what can be done during compile time.

I wouldn't bother -- as soon as Zope3 comes out, all of this will work
without hacking the Python core.  There is very little chance that such
changes will be accepted by Guido, so it is up to you to decide if this
issue is worth diverging from the stock interpreter.  Esepcially since you
can do the following in the mean time:

class Primary(Persistent):
  def __classinit__(cls):
    # ...

  # ...

# Manually call your own classinit after its definition
# NOTE: This wil go away after Zope3 stops using ExtensionClasses
Primary.__classinit__(Primary)


> I will try to hack a little bit in the source. Thanks

If you are truely intent on doing this, then the call to __initclass__ be
the final step the end of the ReadyClass function.

Regards,
-Kevin

-- 
----------->  Kevin Jacobs  <-----------|------->  (216) 986-0710  <--------
Informatics Consultant                  | Department of Epidemiology
Primary mail:   jacobs at theopalgroup.com |   & Biostatistics
Alternate mail: jacobs at darwin.cwru.edu  | Case Western Reserve University
----------------------------------------------------------------------------



More information about the Python-list mailing list