On Sun, 14 Dec 2008 09:51:03 -0800, Paul Moore wrote: > On 14 Dec, 16:22, Bruno Desthuilliers > <bdesth.quelquech...@free.quelquepart.fr> wrote: >> if you only want the first returned value, you can just apply a slice: >> >> def f(): >> return 1,2,3 >> >> a = f()[0] + 1 > > Hmm, true. I'm not sure it's any less ugly, though :-) > >> FWIW, Python 2.6 has NamedTuple objects... > > I know, but I want to target 2.5+ (I still have a number of systems > running 2.5) >
Ah, that discounts python 3.0 Python 3.0 allows you to do this: a, b, *c = range(5) # a >> 0 # b >> 1 # c >> [2, 3, 4] *a, b, c = range(5) # a >> [0, 1, 2] # b >> 3 # c >> 4 a, *b, c = range(5) # a >> 0 # b >> [1, 2, 3] # C >> 4 -- http://mail.python.org/mailman/listinfo/python-list