Chris Rebert wrote:
On Thu, May 28, 2009 at 3:19 AM,  <dudeja.ra...@gmail.com> wrote:
Hi,

I'm using Python 2.5.2. I'm getting this error whenever I try to unpack less
values from a function.

ValueError: too many values to unpack


I want to know if there is a way I can unpack less values returning from a
function?

Unpack them into throwaway variables:

def foo(): return 1,2,3,4

a, b, _, _ = foo()

In very new Python, you can also do:

a, b, *_ = foo()

Or:

a, b = foo()[ : 2]
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to