Prothon, metaclasses, Zope [Was: A 'Python like' language]

Terry Reedy tjreedy at udel.edu
Sun Mar 28 19:54:11 CEST 2004


"Joe Mason" <joe at notcharles.ca> wrote in message
news:slrnc6ddi6.e5c.joe at gate.notcharles.ca...
> In article <95aa1afa.0403280258.41dc5cd9 at posting.google.com>, Michele
Simionato wrote:
> > Joe Mason <joe at notcharles.ca> wrote in message
news:<slrnc6crti.dit.joe at gate.notcharles.ca>...
> >>
> >> You could just put the function call in your base class's __init__
> >> method.  (Or, in fact, put the code from that call directly there, if
> >> you only care when you inherit from the one Zope class.)
> >
> > Uh? The base class __init__ method is not called when I derive a new
> > class. I want to make the make the check at class level, *before*
> > instantiating.
>
> It is if you call the inherited __init__ method, which you should be
> doing because it probably does important stuff.

?? The derived class __init__ is not called until the first instance is
created, which might be way later or even never in any particular run of
the program.  It does *not* check '*before* instantiating' as M.S. sensibly
wants.

> Why do you care whether it checks before instantiating the class, or
> instantiates the class and then throws an error during __init__?  It's
> not going to make any speed or memory difference to the successful case,
> which is all you care about for performance.

The derived class is created just once.  __init__ is called for every
instance, which could be a large number.

Terry J. Reedy







More information about the Python-list mailing list