anonymous assignment

B

Bruno Desthuilliers

Yves Dorfsman a écrit :
I'm afraid you just don't understand what Python's "variable" are.
You're really worrying about a non-issue here. Seriously.
Than what's the point of wanting a better language if every time we run
in something that looks wrong, or something that could be done better we
should just "get over it" ?

No language can be everything to everyone and still retain any kind of
consistency. And the Python's team really try to keep a good balance
between features and consistency (and so far mostly succeed IHMO).

Now, of course, suggesting features or potential improvements *is* a
good idea (and FWIW there's an official way to do so : PEPs). But this
doesn't mean that each an any such proposition is a good idea by itself,
nor that it makes any sense wrt/ Python's design, nor that it's worth
implementing it.
 
G

Gabriel Genellina

But if this happens in the main part of your script, it could take a
long time before this binding disapear, therefore, the gc won't be able
to clean that one up. In this particular case, it doesn't really matter
(small size), but imagine in a case where we are talking of a list of
list, with potentially large element in the list.

If you have some reasons to believe it's worth to release that last
reference as soon as possible, just do it. `del _` is all you need.
(I may have used `del` to remove a local name no more than once a year...)
 
M

Mark Wooding

Ben Finney said:
It's a terrible name for that purpose, since it doesn't indicate the
intention explicitly,

There's a lot of tradition behind _ for this purpose, not just in
Python. For example, pattern-matching function languages, like ML and
Haskell, have been using _ to mean `don't care' for a long time.

Just the fact that the name is repeated suggests that you don't care
about its value. Besides, it's a good choice for other reasons:
because the symbol is short, the variables you do care about stand out
clearly.
Far better to use the name 'unused' as suggested by Carl Banks earlier
today.

Other traditional names are `hunoz', `hukairz' and (apparently) `huaskt.

But these have much more visual clutter than the humble _. You actually
need to do reading to pick out the bindings which you /are/ interested
in.

-- [mdw]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top