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


Groups > comp.lang.python > #7527

Re: dummy, underscore and unused local variables

References <20110613153702.GN2556@johnsons-web.com>
Date 2011-06-14 01:55 +1000
Subject Re: dummy, underscore and unused local variables
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.179.1307980527.11593.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jun 14, 2011 at 1:37 AM, Tim Johnson <tim@johnsons-web.com> wrote:
> 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.

_ is special to IDLE.


>>> 1+2
3
>>> _
3

It's the last result. So presumably when you did it, your last result
was something boolean.

>>> sorted([random.randint(1,10) for i in range(10)])
[1, 1, 2, 3, 4, 4, 5, 7, 8, 10]
>>> set(_)
{1, 2, 3, 4, 5, 7, 8, 10}

Can be quite handy, if you remember it's there. Otherwise, not so much. :)

Chris Angelico

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


Thread

Re: dummy, underscore and unused local variables Chris Angelico <rosuav@gmail.com> - 2011-06-14 01:55 +1000
  Re: dummy, underscore and unused local variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-13 16:15 +0000
    Re: dummy, underscore and unused local variables Chris Angelico <rosuav@gmail.com> - 2011-06-14 02:41 +1000

csiph-web