Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7527 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2011-06-14 01:55 +1000 |
| Last post | 2011-06-14 02:41 +1000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-06-14 01:55 +1000 |
| Subject | Re: dummy, underscore and unused local variables |
| Message-ID | <mailman.179.1307980527.11593.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-06-13 16:15 +0000 |
| Message-ID | <4df63791$0$30002$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #7527 |
On Tue, 14 Jun 2011 01:55:04 +1000, Chris Angelico wrote: > 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. Not just IDLE. Also the vanilla Python command line interpreter. In fact, you can even find the code that controls it: help(sys.displayhook) http://docs.python.org/library/sys.html#sys.displayhook -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-06-14 02:41 +1000 |
| Message-ID | <mailman.183.1307983283.11593.python-list@python.org> |
| In reply to | #7531 |
On Tue, Jun 14, 2011 at 2:15 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Tue, 14 Jun 2011 01:55:04 +1000, Chris Angelico wrote: >> _ is special to IDLE. > > Not just IDLE. Also the vanilla Python command line interpreter. In fact, > you can even find the code that controls it: Sorry, my bad! I should have said "to the Python interactive interpreter", the code that backs IDLE and the command line interpreter. But in any case, it's a feature of the interactive that doesn't apply to scripts. ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web