anonymous assignment
Arnaud Delobelle
arnodel at googlemail.com
Mon May 12 02:31:32 EDT 2008
Yves Dorfsman <yves at zioup.com> 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
More information about the Python-list
mailing list