471,310 Members | 1,214 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

List of avaliable Partitions

Beshr
4
Hey all!

Another fast question!

How can I get a list of all available hard disk partitions on the current computer!

I managed to work out one my self but it works only with Windows! Any one knows a Cross-platform way? I want it to work on my linux!

thnx
Dec 21 '07 #1
1 1479
STM
4
on linux it would be easier to use the shell and do something like:

Expand|Select|Wrap|Line Numbers
  1. cat /proc/partitions
this would be one way to make your program more portable:
Expand|Select|Wrap|Line Numbers
  1. from sys import platform
  2. from os import system
  3.  
  4. if 'linux' in platform:
  5.     system('cat /proc/partitions')
  6. else: 
  7.     #your windows version of the program would go here
or instead of using sys.platform you could use sys.version to distinguish between various linux distros.
Dec 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Elaine Jackson | last post: by
reply views Thread by Heiko Wundram | last post: by
6 posts views Thread by cantabile | last post: by
3 posts views Thread by Amit | last post: by
8 posts views Thread by arunrocks | last post: by
1 post views Thread by Computer Guru | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.