apply problem

Heiko Wundram heikowu at ceosg.de
Mon Jul 2 19:34:45 EDT 2001


Hey to all fellow Python users!

I have a (strange) problem using apply under Python 2.1.

I have a function in a class, that wishes to call another function in the 
same class whose name it receives as a name.

I use the following code:

      apply(getattr(self,name),(attrs))

where name is the name of the function to call, and attrs is a variable (a 
dictionary) that is passed in to the function as well.

Python comes with a very funny error message when I try to run this code:

It throws a KeyError exception with the key being zero!

What is wrong here? I have absolutely no clue, as the documentation of 
apply is, well, quite short. ;)

Any help is appreciated!

Yours,

        Heiko W.



More information about the Python-list mailing list