anonymous assignment
Yves Dorfsman
yves at zioup.com
Sun May 11 23:40:03 EDT 2008
Paul Rubin wrote:
> Yves Dorfsman <yves at zioup.com> writes:
>> 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.
>
> 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... I don't want to compare languages, but I find the
perl "undef" elegant.
Yves.
http://www.SollerS.ca
More information about the Python-list
mailing list