Variable arguments to a Python function

Mahboob mahboob at bellsouth.net
Thu May 29 00:22:11 EDT 2003


How can I pass variable number of arguments to a Python function and access
them inside the function?

In Perl, you could write

sub all_of {
    my $result = 1;
    while ( @_) {
        $result *= shift;
       }
    return result;
}
(From Mastering Algorithms with Perl, pg 569)
You can compute the product of any number of variables with the above
function.

Thanks,
-- Mahboob







More information about the Python-list mailing list