On Fri, May 2, 2008 at 12:08 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > I need to use a regular expression to get a couple of items for my python > script. So far the script is running an 'ls' command to get a few items > that I need
Why do you need to use regular expressions? This problem doesn't really seem to call for them. You should be able to just use the split method of strings. Here's an example: IDLE 1.2.2 >>> command1 = "2454112 /xen/domains2/machinename/disk.img" >>> command2 = "-rw-r--r-- 1 root root 20980736 May 2 10:05 /xen/domains2/machinename/disk.img" >>> command1.split() ['2454112', '/xen/domains2/machinename/disk.img'] >>> command2.split() ['-rw-r--r--', '1', 'root', 'root', '20980736', 'May', '2', '10:05', '/xen/domains2/machinename/disk.img'] >>> bytes_used = command1.split()[0] >>> bytes_actual = command2.split()[4] >>> print bytes_used 2454112 >>> print bytes_actual 20980736 >>> percent = float(bytes_used) / float(bytes_actual) >>> percent 0.11696977646542046 >>> -- Jerry _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor