Init a table of functions

Andrew Dalke adalke at
Sun Oct 10 05:56:13 CEST 2004

Richard Blackwood wrote:
> Yo Andrew.  That doesn't work.  Check my previous post w/ errors.

What do you mean?

Ahh, I see I solved the first problem (can't find 'foo')
without solving what the OP wanted.  Try this reordering.

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

      def f2():
           print "f2"

      K={"f1" : f1,
         "f2" : f2,
      f1 = staticmethod(f1)
      f2 = staticmethod(f2)

def main():

if __name__ == "__main__":

The 'staticmethod' is a descriptor and only works in
the context of a class.

Functions get turned into methods only in the context
of a class.

So to use a function as a function, get it before it
turns into a method or staticmethod.

				dalke at

More information about the Python-list mailing list