None

Lee Harr missive at frontiernet.net
Sun Nov 2 10:31:19 EST 2003


> def executer(func, para):
>  func(para)
>
> def foo():
>  print "function without parameter"

How about:

def foo(arg=None):
    if arg is not None:
        raise TypeError
    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?
>
> is there a way to allow parameterless functions as parameter in executer?
>


I sometimes run in to this situation when creating callback functions.
What if I want to call the function standalone, and not as a callback?

I just use this trick and set the extra parameters to default to None.





More information about the Python-list mailing list