MOTD

Message Of The Day

Fri, 28 Jan 2005

08:59 [zork(~)] cat cool-python-idiom.txt

Cool Python Idiom

This is a handy thing if you are playing with big stuff in the python repl.

import os
less = os.popen('less', 'w')
less.write( ... bunch of data written out here ...)
less.close()

The great thing is also that you can pass less anywhere that you have a filehandle that you're writing to.

Beaujolais!

What would be really great is if you could make a file object that would invoke less if you have more than $LINES of output in a go. Then you could do:

sys.stdout = less_stdout()

or somesuch.

That would be totally bitchin.


[zork(~)] cal
[zork(~)] tree
[zork(~)] syndicate.py
[zork(~)] cat README