On Thu, Feb 5, 2009 at 7:03 PM, Vincent Davis <vinc...@vincentdavis.net> wrote:
> Is it correct that if I want to return multiple objects from a function I
> need to in some way combine them?
> def test1():
>     a = [1,3,5,7]
>     b = [2,4,6,8]
>     c=[a,b]
>    return a, b # this does not work?
>    return [a, b] # does not work?
>    return c # this works but I don't like it, , is there a better way?

All 3 of those *do work* just fine.
I suspect you happen to not be familiar with how to retrieve the
multiple results.

Here's how:

q, w = test1()
print q # prints [1,3,5,7]
print w # prints [2,4,6,8]

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to