I should say I\'m looking for a solution to the problem of viewing output that does not fit on your screen. For example, range(100) will show the last 30ish lin
just for fun :o)
Original version for Python2:
class Less(object):
def __init__(self, num_lines):
self.num_lines = num_lines
def __ror__(self, other):
s = str(other).split("\n")
for i in range(0, len(s), self.num_lines):
print "\n".join(s[i: i + self.num_lines])
raw_input("Press for more")
less = Less(num_lines=30)
"\n".join(map(str, range(100))) | less
a Python3 version:
class Less(object):
def __init__(self, num_lines):
self.num_lines = num_lines
def __ror__(self, other):
s = str(other).split("\n")
for i in range(0, len(s), self.num_lines):
print(*s[i: i + self.num_lines], sep="\n")
input("Press for more")
less = Less(num_lines=30)
"\n".join(map(str, range(100))) | less