4 Jul 18:51
Feature: string list 'sort()' method added
From: Ville M. Vainio <vivainio <at> gmail.com>
Subject: Feature: string list 'sort()' method added
Newsgroups: gmane.comp.python.ipython.user
Date: 2008-07-04 16:55:00 GMT
Subject: Feature: string list 'sort()' method added
Newsgroups: gmane.comp.python.ipython.user
Date: 2008-07-04 16:55:00 GMT
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'
RSS Feed