return multiple objects

Vincent Davis vincent at vincentdavis.net
Thu Feb 5 22:03:01 EST 2009


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?

I saw examples where dictionaries where used but I would prefer to
just access the object names directly. As in

test1()
print a # not haing to refer to it as

is there something I am missing?


Thanks
Vincent Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090205/7fe717c2/attachment.html>


More information about the Python-list mailing list