Backward chaining for __init__?

Donald Beaudry donb at init.com
Wed May 3 10:18:27 EDT 2000


neelk at brick.cswv.com (Neel Krishnaswami) wrote,
> Courageous <jkraska1 at san.rr.com> wrote:
> > How does one go about implementing backward chaining for
> > constructor's in Python?
> 
> Admittedly, this is kind of a let-down if you're used to Common Lisp's
> baroquely overengineered method modifers :), but it works.

Of course, one could always use metaclasses and bytecode hacks to
duplicate Common Lisp's behavior.

Making something like this do the obvious, comes to mind.

    class spam(pork_by_products):
        def __init_before__(self):
            # base class __init__ has not yet been called

        def __init_after__(self):
            # base class __init__ has already been called



--
Donald Beaudry                                     Ab Initio Software Corp.
                                                   201 Spring Street
donb at init.com                                      Lexington, MA 02421
                  ...So much code, so little time...





More information about the Python-list mailing list