1

This is my code:

import commands

mount = commands.getoutput('mount -v')
lines = mount.splitlines()
points = map(lambda line: line.split()[2], lines)
permission = map(lambda line: line.split()[5], lines)
print points
print permission

The output I am getting is:

['/', '/proc', '/sys', '/dev/pts', '/dev/shm', '/boot', '/proc/sys/fs/binfmt_misc', '/var/lib/nfs/rpc_pipefs']
['(rw)', '(rw)', '(rw)', '(rw,gid=5,mode=620)', '(rw,rootcontext="system_u:object_r:tmpfs_t:s0")', '(rw)', '(rw)', '(rw)']

I want to display permission of each partition in front of it. Like:

'/'        (rw)
'/proc'    (rw)

and so on. How can it be done?

1 Answer 1

1

you can use zip function for this

>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zipped = zip(x, y)
>>> zipped
[(1, 4), (2, 5), (3, 6)]

in your case

zipped = zip(points, permission)
for i, j in zipped:
    print i, j 

for more details look here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.