anonymous assignment
Ben Finney
bignose+hates-spam at benfinney.id.au
Mon May 12 02:27:46 EDT 2008
Yves Dorfsman <yves at zioup.com> writes:
> 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.
No, you have one extra unused name binding. The values that you don't
want to use have *already* been allocated by the time the above
statement is executed. Name binding doesn't copy the values, it merely
binds a name to them. There's no "variable" in the above statement.
--
\ “Holy human pressure cookers, Batman!” —Robin |
`\ |
_o__) |
Ben Finney
More information about the Python-list
mailing list