Returning a variable number of things...

r0g at
Fri Feb 6 19:50:05 CET 2009

Hi There,

I have a function that uses *args to accept a variable number of
parameters and I would like it to return a variable number of objects.

I could return a list but I would like to take advantage of tuple
unpacking with the return values e.g.

def unpack_struct( a_string, *args ):
  output_vars = []
  for each in *args:
    <<< build a list of output values >>>
  return <<< the tuple equivalent of this list >>>

ip, meat, zipcode = unpack_struct( "", 15, 3, 5 )



More information about the Python-list mailing list