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] print(lines) points = map(lambda word: word.split(), lines) print(points) --------- 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 == 'map': word = word.split() else: word = word.split() thank you!