On May 12, 7:31 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Yves Dorfsman <[EMAIL PROTECTED]> writes: > > Is there anyway to tell python I don't care about a value ? > > > Say I want today's year and day, I'd like to do something like: > > > import time > > y, None, d, None, None, None, None = time.localtime() > > > I know you can't assign anything to None, but I'm sure you get what I > > mean, a special keyword that means I don't care about this value. In > > this particular case, there's got to be a better way than: > > > d = time.local() > > y = d[0] > > d = d[1] > > I use Paul Rubin's solution (which is frown upon by many:), but it's > true it would be nice for tuples to have something like an extract() > method: > > y, d = time.localtime.extract(0, 2) > > Where > > mytuple.extract(i1, i2, i3...) > > would mean: > > tuple(mytuple[i] for i in (i1, i2, i3...)) > > Or perhaps allow indexing by tuples: > > mytuple[i1, i2, i3...] > > -- > Arnaud
here is a very sophisticated implementation :) >>> def extract(indices, seq): ... return tuple(seq[i] for i in indices) ... >>> y, d = extract((0, 2), time.localtime()) >>> y, d (2008, 12) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list