[IPython-user] Feature: string list 'sort()' method added

Ville M. Vainio vivainio@gmail....
Fri Jul 4 11:55:00 CDT 2008


Typically, you can't be bothered to remember the flags all the system
commands use for sorting the output. SList.sort() helps here (field 4
is the fifth field, the numeric size):

[docs/howto]|41> a = !ls -l
[docs/howto]|42> a
            <42> SList (.p, .n, .l, .s, .grep(), .fields(), sort() ava
ilable):
0: total 52
1: -rw-r--r-- 1 ville ville  2702 2008-05-15 14:07 html-stylesheets.tx
t
2: -rw-r--r-- 1 ville ville  7301 2008-05-15 14:07 i18n.txt
3: -rw-r--r-- 1 ville ville 16428 2008-05-15 14:07 rst-directives.txt
4: -rw-r--r-- 1 ville ville  8662 2008-05-15 14:07 rst-roles.txt
5: -rw-r--r-- 1 ville ville  5800 2008-05-15 14:07 security.txt
[docs/howto]|43> a.sort(4, nums = True)
            <43> SList (.p, .n, .l, .s, .grep(), .fields(), sort() available):
0: total 52
1: -rw-r--r-- 1 ville ville  2702 2008-05-15 14:07 html-stylesheets.tx
               t
2: -rw-r--r-- 1 ville ville  5800 2008-05-15 14:07 security.txt
3: -rw-r--r-- 1 ville ville  7301 2008-05-15 14:07 i18n.txt
4: -rw-r--r-- 1 ville ville  8662 2008-05-15 14:07 rst-roles.txt
5: -rw-r--r-- 1 ville ville 16428 2008-05-15 14:07 rst-directives.txt
[docs/howto]|44>

I also changed '%cpaste foo' to assign the pasted block to foo as
string list (which is much more useful than just assigning as string).

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-user mailing list