anonymous assignment
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon May 12 02:05:14 EDT 2008
On Mon, 12 May 2008 03:40:03 +0000, Yves Dorfsman wrote:
> Paul Rubin wrote:
>
>> You can just use a variable name than you ignore. It's traditional to
>> use _ but it's not a special keyword, it's just a another variable
>> name:
>>
>> y, _, d, _, _, _, _, _, _ = time.localtime()
>
> But you still have have a variable that's using memory for nothing. I
> find this unsatisfactory...
Get over it…
Or use `operator.itemgetter()`:
In [36]: operator.itemgetter(0, 2)(time.localtime())
Out[36]: (2008, 12)
:-)
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list