Using an interable in place of *args?

Michael Hudson mwh at python.net
Fri Nov 21 12:01:58 EST 2003


Nick Vargish <nav+posts at bandersnatch.org.invalid> writes:

> Is there a general method for calling a function that expects *args
> with an iterable instead (tuple or, even better, a list)? I can see
> how I could do something funky with exec, but I'd like to avoid that
> if possible.

Are you just asking for *arg?

>>> struct.pack('c'*4, *(['e']*4))
'eeee'

Cheers,
mwh

-- 
  Get out your salt shakers folks, this one's going to take more
  than one grain.                 -- Ator in an Ars Technica news item




More information about the Python-list mailing list