Converting a tuple to an argument list for a method?

Steve Holden sholden at holdenweb.com
Thu Oct 18 08:40:15 EDT 2001


"Gabriel Ambuehl" <gabriel_ambuehl at buz.ch> wrote in message
news:mailman.1003398391.16015.python-list at python.org...
> -----BEGIN PGP SIGNED MESSAGE-----
>
> Hello,
> I'm messing with the XMLRPC implementation from PythonWare which
> makes the arguments to the request available as tuple but the
> method's
> I want to call expect a normal argument list as their parameters.
>
> So xmlprc delivers:
> xmlrpcparam=(param1, param2, param....)
> which won't work for
> method(param1, param2, param3)
> because the tuple only counts as one argument. So is there a
> possibility to use the tuple (which hasn't got a fixed length cause
> different methods on the server need different numbers of arguments,
> else it would be easy to just do
> method(xmlrpcparam[0], xmlrpcmethod[1])) to form an argument list for
> the methods on the server?
>
> Currently less important: is there a way to use named arguments with
> xmlrpc so that the server could decide whether the format of the
> clients request is valid?
>
> Any comments would be greatly appreciated.
>
Without testing, it looks like

    method(*xmlrpcparam)

ought to work for you. Each element of the tuple becomes a positional
argument.

>>> def one(a,b,*rest):
...  print "a:", a, "b:", b, "rest:", rest
...
>>> one(*("A","B","C","D"))
a: A b: B rest: ('C', 'D')
>>>

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list