dummy, underscore and unused local variables
Chris Angelico
rosuav at gmail.com
Mon Jun 13 11:55:04 EDT 2011
On Tue, Jun 14, 2011 at 1:37 AM, Tim Johnson <tim at 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
More information about the Python-list
mailing list