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


Groups > comp.lang.python > #49249

Re: Limit Lines of Output

From Alister <alister.ware@ntlworld.com>
Subject Re: Limit Lines of Output
Newsgroups comp.lang.python
References <0cb638ec-a4bd-4a45-b98c-a7c76996bab7@googlegroups.com> <mailman.3844.1372191538.3114.python-list@python.org> <842bc651-0bed-45df-9a29-2049279f4434@googlegroups.com> <CAN1F8qW2fKmZgS8HrMJ4Fn3QVskW11p=32w-dz4G2E_kk1_RXA@mail.gmail.com> <mailman.3847.1372192816.3114.python-list@python.org>
Message-ID <SrAyt.3$ds7.0@fx36.am4> (permalink)
Organization virginmedia.com
Date 2013-06-26 11:41 +0000

Show all headers | View raw


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

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


Thread

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

csiph-web