Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49183 > unrolled thread
| Started by | Bryan Britten <britten.bryan@gmail.com> |
|---|---|
| First post | 2013-06-25 13:09 -0700 |
| Last post | 2013-06-27 01:58 +1000 |
| Articles | 17 — 10 participants |
Back to article view | Back to comp.lang.python
Limit Lines of Output Bryan Britten <britten.bryan@gmail.com> - 2013-06-25 13:09 -0700
Re: Limit Lines of Output Joel Goldstick <joel.goldstick@gmail.com> - 2013-06-25 16:18 -0400
Re: Limit Lines of Output Bryan Britten <britten.bryan@gmail.com> - 2013-06-25 13:22 -0700
Re: Limit Lines of Output Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-25 21:31 +0100
Re: Limit Lines of Output Joel Goldstick <joel.goldstick@gmail.com> - 2013-06-25 16:33 -0400
Re: Limit Lines of Output Bryan Britten <britten.bryan@gmail.com> - 2013-06-25 13:37 -0700
Re: Limit Lines of Output Dave Angel <davea@davea.name> - 2013-06-25 22:27 -0400
Re: Limit Lines of Output Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-25 14:39 -0600
Re: Limit Lines of Output Alister <alister.ware@ntlworld.com> - 2013-06-26 11:41 +0000
Re: Limit Lines of Output Gene Heskett <gheskett@wdtv.com> - 2013-06-25 17:48 -0400
Re: Limit Lines of Output Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-26 16:24 +0100
Re: Limit Lines of Output Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-26 16:46 +0000
Re: Limit Lines of Output Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-26 23:07 +0100
Re: Limit Lines of Output rusi <rustompmody@gmail.com> - 2013-06-26 10:09 -0700
Re: Limit Lines of Output Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-26 23:57 +0000
Re: Limit Lines of Output Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-27 13:54 +0100
Re: Limit Lines of Output Chris Angelico <rosuav@gmail.com> - 2013-06-27 01:58 +1000
| From | Bryan Britten <britten.bryan@gmail.com> |
|---|---|
| Date | 2013-06-25 13:09 -0700 |
| Subject | Limit Lines of Output |
| Message-ID | <0cb638ec-a4bd-4a45-b98c-a7c76996bab7@googlegroups.com> |
Hey, group, quick (I hope) question: I've got a simple script that counts the number of words in a data set (it's more complicated than that, but that's one of the functions), but there are so many words that the output is too much to see in the command prompt window. What I'd like to be able to do is incorporate the "More..." feature that help libraries have, but I have no idea how to do it. I also don't know if I'm asking the question correctly because a Google search yielding nothing. Any insight would be appreciated. Thanks!
[toc] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-06-25 16:18 -0400 |
| Message-ID | <mailman.3844.1372191538.3114.python-list@python.org> |
| In reply to | #49183 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jun 25, 2013 at 4:09 PM, Bryan Britten <britten.bryan@gmail.com>wrote: > Hey, group, quick (I hope) question: > > I've got a simple script that counts the number of words in a data set > (it's more complicated than that, but that's one of the functions), but > there are so many words that the output is too much to see in the command > prompt window. What I'd like to be able to do is incorporate the "More..." > feature that help libraries have, but I have no idea how to do it. I also > don't know if I'm asking the question correctly because a Google search > yielding nothing. > > Any insight would be appreciated. Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > If you are using linux, you should look up the comand 'less'. It allows you to page thru a test file. You can either write your list to a file or pipe it into less (haven't tried that myself) -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Bryan Britten <britten.bryan@gmail.com> |
|---|---|
| Date | 2013-06-25 13:22 -0700 |
| Message-ID | <842bc651-0bed-45df-9a29-2049279f4434@googlegroups.com> |
| In reply to | #49185 |
Ah, I always forget to mention my OS on these forums. I'm running Windows.
[toc] | [prev] | [next] | [standalone]
| From | Joshua Landau <joshua.landau.ws@gmail.com> |
|---|---|
| Date | 2013-06-25 21:31 +0100 |
| Message-ID | <mailman.3845.1372192355.3114.python-list@python.org> |
| In reply to | #49186 |
On 25 June 2013 21:22, Bryan Britten <britten.bryan@gmail.com> wrote:
> Ah, I always forget to mention my OS on these forums. I'm running Windows.
Supposedly, Windows has "more"
[http://superuser.com/questions/426226/less-or-more-in-windows],
For Linux+less; this works:
from subprocess import Popen, PIPE
less = Popen("less", stdin=PIPE)
less.stdin.write(b"\n".join("This is line number
{}".format(i).encode("UTF-8") for i in range(1000)))
less.wait()
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-06-25 16:33 -0400 |
| Message-ID | <mailman.3846.1372192411.3114.python-list@python.org> |
| In reply to | #49186 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jun 25, 2013 at 4:22 PM, Bryan Britten <britten.bryan@gmail.com>wrote: > Ah, I always forget to mention my OS on these forums. I'm running Windows. > > -- > http://mail.python.org/mailman/listinfo/python-list > I don't think I fully understand your problem. Why can't you send output to a text file, then use a text editor to view results? -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Bryan Britten <britten.bryan@gmail.com> |
|---|---|
| Date | 2013-06-25 13:37 -0700 |
| Message-ID | <2d9f3f9a-6fee-42db-ad6e-acc7eaf7c195@googlegroups.com> |
| In reply to | #49188 |
Joel - I don't want to send it to a text file because it's just meant to serve as a reference for the user to get an idea of what words are mentioned. The words being analyzed are responses to a survey questions and the primary function of this script is to serve as a text analytics program. Exporting the output to a text file would just be an unnecessary/undesirable step for the user.
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-06-25 22:27 -0400 |
| Message-ID | <mailman.3874.1372213655.3114.python-list@python.org> |
| In reply to | #49189 |
On 06/25/2013 04:37 PM, Bryan Britten wrote: > Joel - > > I don't want to send it to a text file because it's just meant to serve as a reference for the user to get an idea of what words are mentioned. The words being analyzed are responses to a survey questions and the primary function of this script is to serve as a text analytics program. Exporting the output to a text file would just be an unnecessary/undesirable step for the user. > Your subject says you want to limit the lines of output. So after 25 lines, quit the program. Not too hard. At the other extreme, your user wants to be able to scroll up or down within the hundreds of lines, seeing 25 at a time, and wants to be able to search for particular substrings, optionally with case-insensitivity, and wants to be able to sort them by some criteria, or copy/paste some portion elsewhere. Write a spec that limits what you want, or you'll never finish the project. And accept that if you want too much, you'll end up writing the equivalent of a text editor before you're done. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-06-25 14:39 -0600 |
| Message-ID | <mailman.3847.1372192816.3114.python-list@python.org> |
| In reply to | #49186 |
On Tue, Jun 25, 2013 at 2:31 PM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> On 25 June 2013 21:22, Bryan Britten <britten.bryan@gmail.com> wrote:
>> Ah, I always forget to mention my OS on these forums. I'm running Windows.
>
> Supposedly, Windows has "more"
> [http://superuser.com/questions/426226/less-or-more-in-windows],
>
> For Linux+less; this works:
>
> from subprocess import Popen, PIPE
> less = Popen("less", stdin=PIPE)
> less.stdin.write(b"\n".join("This is line number
> {}".format(i).encode("UTF-8") for i in range(1000)))
> less.wait()
Or simply:
$ python my_script.py | less
It works the same way in Windows:
C:\> python my_script.py | more
[toc] | [prev] | [next] | [standalone]
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2013-06-26 11:41 +0000 |
| Message-ID | <SrAyt.3$ds7.0@fx36.am4> |
| In reply to | #49190 |
On Tue, 25 Jun 2013 14:39:30 -0600, Ian Kelly wrote:
> On Tue, Jun 25, 2013 at 2:31 PM, Joshua Landau
> <joshua.landau.ws@gmail.com> wrote:
>> On 25 June 2013 21:22, Bryan Britten <britten.bryan@gmail.com> wrote:
>>> Ah, I always forget to mention my OS on these forums. I'm running
>>> Windows.
>>
>> Supposedly, Windows has "more"
>> [http://superuser.com/questions/426226/less-or-more-in-windows],
>>
>> For Linux+less; this works:
>>
>> from subprocess import Popen, PIPE less = Popen("less", stdin=PIPE)
>> less.stdin.write(b"\n".join("This is line number
>> {}".format(i).encode("UTF-8") for i in range(1000)))
>> less.wait()
>
>
> Or simply:
>
> $ python my_script.py | less
>
> It works the same way in Windows:
>
> C:\> python my_script.py | more
this would be my approach
it leaves it to the user to decide what to do with the output (they may
even decide to write it to a file themselves)
and obeys to very good principles
1) Do not re-invent the wheel.
2) do only 1 job but do it well.
--
"Every morning, I get up and look through the 'Forbes' list of the
richest people in America. If I'm not there, I go to work"
-- Robert Orben
[toc] | [prev] | [next] | [standalone]
| From | Gene Heskett <gheskett@wdtv.com> |
|---|---|
| Date | 2013-06-25 17:48 -0400 |
| Message-ID | <mailman.3886.1372243291.3114.python-list@python.org> |
| In reply to | #49186 |
On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine:
> On 25 June 2013 21:22, Bryan Britten <britten.bryan@gmail.com> wrote:
> > Ah, I always forget to mention my OS on these forums. I'm running
> > Windows.
>
> Supposedly, Windows has "more"
> [http://superuser.com/questions/426226/less-or-more-in-windows],
Yes, but less is more than more.
> For Linux+less; this works:
>
> from subprocess import Popen, PIPE
> less = Popen("less", stdin=PIPE)
> less.stdin.write(b"\n".join("This is line number
> {}".format(i).encode("UTF-8") for i in range(1000)))
> less.wait()
Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
My views
<http://www.armchairpatriot.com/What%20Has%20America%20Become.shtml>
Campbell's Law:
Nature abhors a vacuous experimenter.
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.
[toc] | [prev] | [next] | [standalone]
| From | Joshua Landau <joshua.landau.ws@gmail.com> |
|---|---|
| Date | 2013-06-26 16:24 +0100 |
| Message-ID | <mailman.3895.1372260345.3114.python-list@python.org> |
| In reply to | #49186 |
On 25 June 2013 22:48, Gene Heskett <gheskett@wdtv.com> wrote: > On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-06-26 16:46 +0000 |
| Message-ID | <51cb1aeb$0$29999$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #49266 |
On Wed, 26 Jun 2013 16:24:56 +0100, Joshua Landau wrote: > On 25 June 2013 22:48, Gene Heskett <gheskett@wdtv.com> wrote: >> On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: > > I did not. Unless there are two people called "Joshua Landau" with email address <joshua.landau.ws@gmail.com>, I'm afraid that you did. Here's the email that started the subthread, by Bryan Britten: http://mail.python.org/pipermail/python-list/2013-June/650697.html Your, or possibly your evil doppelganger's, reply to Bryan: http://mail.python.org/pipermail/python-list/2013-June/650698.html Followed by Gene's reply to your reply: http://mail.python.org/pipermail/python-list/2013-June/650750.html And your, or your evil doppelganger's, reply to Gene: http://mail.python.org/pipermail/python-list/2013-June/650773.html -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Joshua Landau <joshua.landau.ws@gmail.com> |
|---|---|
| Date | 2013-06-26 23:07 +0100 |
| Message-ID | <mailman.3904.1372284481.3114.python-list@python.org> |
| In reply to | #49269 |
On 26 June 2013 17:46, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Wed, 26 Jun 2013 16:24:56 +0100, Joshua Landau wrote: > >> On 25 June 2013 22:48, Gene Heskett <gheskett@wdtv.com> wrote: >>> On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: >> >> I did not. > > Unless there are two people called "Joshua Landau" with email address > <joshua.landau.ws@gmail.com>, I'm afraid that you did. Ah, but as rusi has understood, I did not. (Although "I did not" may itself be opining, that was not the quoted text.) Hey, sometimes I just like being cryptic.
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-06-26 10:09 -0700 |
| Message-ID | <16f3ce2f-4d8b-4c50-955c-9007e6d28776@googlegroups.com> |
| In reply to | #49266 |
On Wednesday, June 26, 2013 8:54:56 PM UTC+5:30, Joshua Landau wrote: > On 25 June 2013 22:48, Gene Heskett wrote: > > On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: > > I did not. I guess Joshua is saying that saying ≠ opining [Or is he opining?]
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-06-26 23:57 +0000 |
| Message-ID | <51cb7ff4$0$29999$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #49270 |
On Wed, 26 Jun 2013 10:09:13 -0700, rusi wrote:
> On Wednesday, June 26, 2013 8:54:56 PM UTC+5:30, Joshua Landau wrote:
>> On 25 June 2013 22:48, Gene Heskett wrote:
>> > On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine:
>>
>> I did not.
>
> I guess Joshua is saying that saying ≠ opining
But it is. From WordNet:
opine
v 1: express one's opinion openly and without fear or
hesitation; "John spoke up at the meeting" [syn: opine,
speak up, speak out, animadvert, sound off]
Admittedly we cannot tell what Joshua's mental state was at the time he
responded to Bryan, he may have been absolutely terrified for all we
know, but there's no sign of this fear, and no reason to think that he
hesitated, given that his response came through a mere nine minutes after
Bryan's comment.
Or if you prefer the Collaborative International Dictionary of English:
Opine \O*pine"\, v. t. & i. [imp. & p. p. Opined; p. pr. & vb.
n. Opining.] [L. opinari, p. p. opinatus; akin to opinus
(in comp.) thinking, and perh. to E. apt: cf. F. opiner.]
To have an opinion; to judge; to think; to suppose. --South.
[1913 Webster]
> [Or is he opining?]
That's just his opinion, man.
*wink*
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Joshua Landau <joshua.landau.ws@gmail.com> |
|---|---|
| Date | 2013-06-27 13:54 +0100 |
| Message-ID | <mailman.3925.1372338104.3114.python-list@python.org> |
| In reply to | #49289 |
On 27 June 2013 00:57, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Wed, 26 Jun 2013 10:09:13 -0700, rusi wrote:
>
>> On Wednesday, June 26, 2013 8:54:56 PM UTC+5:30, Joshua Landau wrote:
>>> On 25 June 2013 22:48, Gene Heskett wrote:
>>> > On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine:
>>>
>>> I did not.
>>
>> I guess Joshua is saying that saying ≠ opining
>
> But it is. From WordNet:
>
> opine
> v 1: express one's opinion openly and without fear or
> hesitation; "John spoke up at the meeting" [syn: opine,
> speak up, speak out, animadvert, sound off]
To give context;
On 25 June 2013 22:48, Gene Heskett <gheskett@wdtv.com> (incorrectly) wrote:
> On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine:
>
> > On 25 June 2013 21:22, Bryan Britten <britten.bryan@gmail.com> wrote:
> > > Ah, I always forget to mention my OS on these forums. I'm running
> > > Windows.
> >
> > Supposedly, Windows has "more"
> > [http://superuser.com/questions/426226/less-or-more-in-windows],
>
> Yes, but less is more than more.
>
> > For Linux+less; this works:
> >
> > from subprocess import Popen, PIPE
> > less = Popen("less", stdin=PIPE)
> > less.stdin.write(b"\n".join("This is line number
> > {}".format(i).encode("UTF-8") for i in range(1000)))
> > less.wait()
As you can see, my quoted text contained no *opinions*, at least of
the nuance that "opine" refers to.
> Admittedly we cannot tell what Joshua's mental state was at the time he
> responded to Bryan, he may have been absolutely terrified for all we
> know, but there's no sign of this fear, and no reason to think that he
> hesitated, given that his response came through a mere nine minutes after
> Bryan's comment.
That's taking a very analytic turn...
To clarify; I did have little hesitation but that was not the grounds
to my objection.
> Or if you prefer the Collaborative International Dictionary of English:
>
> Opine \O*pine"\, v. t. & i. [imp. & p. p. Opined; p. pr. & vb.
> n. Opining.] [L. opinari, p. p. opinatus; akin to opinus
> (in comp.) thinking, and perh. to E. apt: cf. F. opiner.]
> To have an opinion; to judge; to think; to suppose. --South.
> [1913 Webster]
As this accurately sums up, to "opine" requires one to "judge" in some
form, or to be "opinionated"; these are not things I did; I rather
just referenced someone's work without openly judging it and stated
(objectively so, you shall find) that some code worked.
>> [Or is he opining?]
>
> That's just his opinion, man.
>
> *wink*
--
(I wasn't expecting this to spawn so much discourse.)
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-27 01:58 +1000 |
| Message-ID | <mailman.3897.1372262338.3114.python-list@python.org> |
| In reply to | #49186 |
On Thu, Jun 27, 2013 at 1:24 AM, Joshua Landau <joshua.landau.ws@gmail.com> wrote: > On 25 June 2013 22:48, Gene Heskett <gheskett@wdtv.com> wrote: >> On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: > > I did not. Beg pardon? It looked like an accurate citation to me - you quoted the OP's second post, then added the line beginning "Supposedly". That's what Gene quoted, so I'm not understanding this rejection. ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web