John Roth newsgroups at
Sun Nov 2 13:37:33 CET 2003

"Daniel Schüle" <for_usenet2000 at> wrote in message
news:bo2t4k$p3f$1 at
> 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
> 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?

None is an object like any other object in Python. It's conventional
uses are as a return value from functions that don't return a value,
and as an initial value for optional function parameters. These are
conventional; they are not mandated by the language (except that
the return statement without parameters does return None.)
> is there a way to allow parameterless functions as parameter in executer?

I'm not sure what you mean by this question. Functions are first class
objects, so you can, of course, pass them to other functions. There
are numerous examples in the standard library of methods which
take functions as a parameter. Look at, for example, the map(),
reduce() and filter() built-in functions, and also at the .sort() method
of lists.

John Roth
> --
> Daniel

More information about the Python-list mailing list