Q: going from tuple to comma-separated list?
Erik Max Francis
max at alcyone.com
Tue May 21 02:37:04 EDT 2002
Damian Menscher wrote:
> I've got a function that takes an arbitrary number of parameters.
> (This is the Gnuplot.plot() function.) I don't know until runtime
> how many things I want to send to it. So I thought I'd be clever
> and do it as
> plotdata = ()
> for i in range(stuff):
> plotdata = plotdata + (function(i),)
> Gnuplot.plot(plotdata)
>
> But the plot function is dying due to:
> TypeError: bad argument type for built-in operation
If f is a function and args is a tuple of the arguments you want to send
it, try:
apply(f, args)
or just
f(*args)
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Who'd ever think it / Such a squalid little ending
\__/ The American and Florence, _Chess_
Church / http://www.alcyone.com/pyos/church/
A lambda calculus explorer in Python.
More information about the Python-list
mailing list