an apply question

Emile van Sebille emile at fenx.com
Tue Dec 5 19:00:19 EST 2000


Try it without the quotes around the functions.

eg: 'Key1' = func1

Emile van Sebille
emile at fenx.com



Alan Marchand wrote:

> In Python 2.0:
> 
> What am I doing wrong?
> 
> #!/bin/env python
> #############
> MyMap = {
> 'Key1' : 'func1',
> 'Key2' : 'func2',
> 'Key3' : 'func3',
> 'Key4' : 'func4'
> }
> 
> def func1 ( ):
>     print "Here's func1"
> 
> items = MyMap.items( )
> for x in range( len(items) ):
>     key, func = items[x]
>     if key == "Key3":
>         apply( func, ( ) )
> -------------------------
> c:\devpy\python test.py
> 
> Traceback (most recent call last):
>   File "test.py", line 17, in ?
>     apply( func, ( ) )
> TypeError: Call of non-function (type string)
> 
> Thanks.
> Alan.




More information about the Python-list mailing list