I'm amazed that this works.  I had not realized that

x,y= [3,4]

is equivalent to

x= 3; y= 4

Python is rather clever.

Thanks!

<snip>

To elaborate on Paul's answer, returning the list will also unpack it if 
you have it set up that way.  E.g.

def func(alist):
    return alist

some_list = [1, 2]
this, that = func(alist)

At least, in 2.5.4 this works.  :-)

Mind you, if you don't have the correct number of return names to match 
the unpacking you'll get the normal errors from that.

Hope this helps!

~Ethan~
-- 
http://mail.python.org/mailman/listinfo/python-list



-- 
View this message in context: 
http://www.nabble.com/Is-there-a-better-way-to-code-variable-number-of-return-arguments--tp25803294p25813206.html
Sent from the Python - python-list mailing list archive at Nabble.com.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to