None
Peter Otten
__peter__ at web.de
Sun Nov 2 07:56:14 EST 2003
Daniel Schüle wrote:
> 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)
[...]
> is there a way to allow parameterless functions as parameter in executer?
You can change executer() to accept and pass and arbitrary number of
arguments:
def executer(func, *args):
func(*args)
executer(bar, 100)
executer(foo)
However, excecuter(foo, None) will still fail. See
http://www.python.org/doc/current/tut/node6.html for the details.
As an aside, do the newsgroup - and yourself - a favour and increase your
block indent to 4 spaces.
Peter
More information about the Python-list
mailing list