Steve wrote:
> This is an interesting question.  It almost looks like a case of
> event-driven programming, where main is the plug-in and abc is the
> framework.
> http://eventdrivenpgm.sourceforge.net/
>
> So how about something like this:
>
> ################## abc.py ####################
>
> #------------------------------------------------------------
> # an "abstract" function.
> # It should be over-ridden in the calling program
> #------------------------------------------------------------
> def m():
>       raise AssertionError("You should have over-ridden abstract function
> m()")
>
> def a():
>     m()
>     return None
>
>
> ########### main.py ####################
> import abc  # "instantiate" the framework
>
> # define our our "concrete" function m
> def m():
>     print 'something'
>     return None
>
> #-----------------------------------------------
> # override the "abstract" function abc.m()
> # with our own "concrete" function m().
> # Comment out this line and see what happens.
> #-----------------------------------------------
> abc.m = m
>
> # invoke the a() function in the abc framework
> abc.a()
>
> #################################################

Thank you Steve.

You are correct, the project that I'm working on is an event drive
program.  And your solution works perfectly for this simple example.
My poroject does actually have what you called an "abstract" function.
Now I will know try to implement it into my project.

Thanks again.
Jim

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to