Mel Wilson mwilson at
Sun Nov 2 15:19:06 CET 2003

In article <bo2t4k$p3f$1 at>,
"Daniel Schüle" <for_usenet2000 at> wrote:
>Hi NG
>def executer(func, para):
> func(para)
>def foo():
> print "function without parameter"
>def bar(a):
> print "function with 1 parameter"
> print a
>#executer(foo, None)    #error
>executer(bar, 100)
>print type(foo)
>print type(bar)
>#seem to have the same type, though one takes parameter and the other doesnt
>does this mean that None *is* a value
>some special value to show that variable cant be initialized with more
>appreciate value
>at this stage?

That's what it means.  The way to call foo is `foo()`.
>is there a way to allow parameterless functions as parameter in executer?

        def executer (func, para):
            foo (*para)

will allow you to specify the parameter list explicitely.  Then

        executer (foo, ())
        executer (bar, (1,))
        def baz (a, b):
            print "2 params:", a, b

        executer (baz, (1, 2))

        Regards.        Mel.

More information about the Python-list mailing list