function override???

Oleg Broytmann phd at phd.russ.ru
Tue Nov 16 12:17:42 EST 1999


On Tue, 16 Nov 1999, Arinte wrote:
> I am defining a python callback for my embedded app, but I want the script
> writer to override my function.  So, basically what I want is a function
> prototype.  Ex. here is what I am thinking.
> 
> ;---fprot.py
> def overrideme(self, str, someint)
> 
> ;--fimp.py
> import fprot   #I know this ain't right.
>                           # I don't know how to import from other python
> scripts yet.  Enlighten me?

   I ithink it is correct. Why do you think it is not?

> def overrideme(self, str, someint)
>     do_some_junk()

   Define your procedure:

;---fprot.py
def overrideme(self, str, someint):
   pass

;--fimp.py
import fprot

   And assign your override function:

fprot.overrideme = my_override

   After this, call fprot.overrideme from any place (C or Python).

Oleg.
---- 
    Oleg Broytmann      Foundation for Effective Policies      phd at phd.russ.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list