trentm at ActiveState.com
Tue Jun 14 17:46:42 CEST 2005
[Peter Hansen wrote]
> Richard Lewis wrote:
> > If you want to know where a particular directory is (on a Windows
> > 'drive') you could use:
> > for drive_label in ["C", "D"]:
> > if "Program Files" in os.listdir(drive_label + ":/"): return
> > drive_label
> This would cause trouble in at least two cases that I've seen. One was
> a multiboot machine that had Windows 2000 on D: and Windows XP on C:.
> The other was a machine that had the Program Files folder copied, for
> reasons I don't recall (and perhaps only temporarily), to the D: drive.
And on non-English locales the folder name isn't actually "Program
Files". And on some 64-bit architectures you can have "Program Files"
and "Program Files (x86)". :)
> Use one of the defined APIs for getting this information, not a hack
> like this please.
TrentM at ActiveState.com
More information about the Python-list