Partition names with Python
jdhunter at ace.bsd.uchicago.edu
Mon Jun 30 17:47:54 CEST 2003
>>>>> "Erhan" == Erhan Ekici <erhan at uzem.itu.edu.tr> writes:
Erhan> Hi, How do I get partition names (i.e. C:\ , D:\ ,E:\ on
Erhan> windows, hda,hda1 , hda2 on Linux machines) using Python.
There is nothing to do this in the standard library as far as I know,
but it is fairly easy to parse the output of fdisk. If you are
running as su
for line in os.popen('/sbin/fdisk -l').readlines():
if line.find('/dev/') !=0: continue
columns = line.split()
Should do it. With a little work, you could modify this to work cross
platform if you have fdisk installed on your win32 machine.
More information about the Python-list