Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7526

Re: dummy, underscore and unused local variables

Subject Re: dummy, underscore and unused local variables
From Philip Semanchuk <philip@semanchuk.com>
Date 2011-06-13 11:50 -0400
References <20110613153702.GN2556@johnsons-web.com>
Newsgroups comp.lang.python
Message-ID <mailman.178.1307980261.11593.python-list@python.org> (permalink)

Show all headers | View raw


On Jun 13, 2011, at 11:37 AM, Tim Johnson wrote:

> NOTE: I see much on google regarding unused local variables, 
> however, doing a search for 'python _' hasn't proved fruitful.

Yes, Google's not good for searching punctuation. But 'python underscore dummy OR unused' might work better.

> On a related note: from the python interpreter if I do
>>>> help(_) 
> I get 
> Help on bool object:
> 
> class bool(int)
> |  bool(x) -> bool
> ......
> I'd welcome comments on this as well.
> 

In the Python interpreter, _ gives you the results of the last expression. When you first start the interpreter, _ is undefined.

$ python
>>> help(_)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> True
True
>>> help(_)

Help on bool object:

class bool(int)
 |  bool(x) -> bool


In your case when you asked for help(_), the last object you used must have been a bool.

> 
> :) I expect to be edified is so many ways, some
> of them unexpected.

That's the nice thing about this list!

Hope this helps
Philip

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: dummy, underscore and unused local variables Philip Semanchuk <philip@semanchuk.com> - 2011-06-13 11:50 -0400

csiph-web