next up previous contents
Next: Lambda And Functional Up: Optional Function Arguments Previous: Default Argument Values

Arbitrary Argument Lists

It is also possible to specify that a function can be called with an arbitrary number of arguments. These arguments will be wrapped up in a tuple. Before the variable number of arguments, zero or more normal arguments may occur, e.g.

        def fprintf(file, format, *args):
                file.write(format % args)

This feature may be combined with the previous, e.g.

        def but_is_it_useful(required, optional = None, *remains):
                print "I don't know"



guido@cwi.nl