anonymous assignment

Paul Rubin http
Sun May 11 22:37:06 EDT 2008


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()



More information about the Python-list mailing list