Map() with lambda


This is from external reading part of Advanced Topics in Python.

Code I wrote is printing correct mount points for some directories. For others that have mount point as 3rd sub string, it is not working. How to formulate lambda correctly for this map() function?

['/', '/dev', 'on', 'on', '/Volumes/MySQL', '/Volumes/Sublime', '/Volumes/Sublime']
this 'on' is coming from:
'map auto_home on /home (autofs, automounted, nobrowse)'

My code is below.

'''unix command to find mount points in the file system'''
import subprocess

mount = subprocess.check_output(["mount", "-v"])
lines = mount.split("\n") [:-1]
points = map(lambda word: word.split()[2], lines)

For the line: 'map auto_home on /home (autofs, automounted, nobrowse)' 
2nd substring is 'on' and not '/home' as i wanted.
How to re-write the lambda function with map()?
I need something like:
if word[0] == 'map':
       word =  word.split()[3]
       word = word.split()[2]

thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.