tags:

views:

407

answers:

0

I've been using Ipython for my command line on XP for, oh... ages! However, being a sucker for the eye-candy I always wanted the console window to be a little cooler e.g. like a Terminal window on Linux.

Today I found Console2 and my heart was filled with joy...

However, there is something rotton in the state of large / multi-line output.

When I try something that might produce a large multi-line output e.g. an alias command or just a large list or dict, I get this kind of thing...

[c:/]|12> alias
Total number of aliases: 860
     <12>

I can get round it easily enough e.g.

[c:/]|19> aliases=_
[c:/]|20> pprint.pprint(aliases)
[('', '.up4vinst'),
 ('a2p', 'a2p'),
 ('accevent32', 'accevent32'),
 ('accevent9x', 'accevent9x'),
 ('accexplorer32', 'AccExplorer32'),
 ('accexplorer9x', 'AccExplorer9x'),
 ('accwiz', 'accwiz'),
 etc...

But it is inconvenient. I'm not sure if the fault is with Console2 or with Ipython, as I have seen this issue with large data lists with a standard cmd shell as well.

Anyone got any ideas about how to 'fix' this?

Hmmm! So some further investigation shows that there is a limit to the size of output that IPython will handle...

I wrote this very quick function to generate a list containing a specified number of characters...

def big_list( size ):
    my_string = "abcdefghigklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    fricking_big_list=[]
    step_size = len(my_string)
    for x in xrange(step_size, size, step_size):
        fricking_big_list.append(my_string)

    remainder= size - ((size / step_size) * step_size)
    if remainder:
        fricking_big_list.append(my_string[0:remainder])

    return fricking_big_list

I ran it from the command line, like so...

[c:/]|206> result = big_list(17909)
[c:/]|207> result
     <207>
[c:/]|208> len(result)
     <208> 345

... and with a total of 17909 characters in the list, it won't display 'result'. However, if I have just one less char...

[c:/]|209> result = big_list(17908)
[c:/]|210> result
     <210>
['abcdefghigklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
 'abcdefghigklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
.
. [snipped]
.
 'abcdefghigklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
 'abcdefghigklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
 'abcdefghigklmnopqrst']
[c:/]|211>

Then Ipython will display the 'result' var.