Init a table of functions

Paulo da Silva psXdaXsilva at esotericaX.ptX
Sun Oct 10 03:32:28 CEST 2004

How do I program something like the folowing program?
PYTHON claims it doesn't know about 'foo' when initializing K!
The only way I got this to work was doing the init of K in
the __init__ func. But this runs everytime for each object!
When using the name of the function without 'foo', I don't
know how to call it!

Thanks for any help.

#! /bin/env python
# -*- coding: iso-8859-15 -*-

class foo:
     def f1():
         print "f1"

     def f2():
         print "f2"

     K={"f1" : foo.f1, \
        "f1" : foo.f2  \

def main():

if __name__ == "__main__":

More information about the Python-list mailing list