[Tutor] Acessing files in Windows 2000

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Mar 9 03:56:44 CET 2005

[Windows bashing cut]

Python's support for Windows stuff is actually quite good, thanks to the
work of Mark Hammond:


A lot of us here do use Windows for COM programming.  Let's get back to
talking about Python programming and let's help Dave with his problem.

The os.path module contains a function called expanduser() that returns
the home directory of a given user.


I believe this should reliably return a path that looks something like
'\\Documents and Settings\\[username]' on Windows systems.

Dave, what happens if you try something like this?

import os.path
print os.path.expanduser('~/memo.txt')
f = open(os.path.expanduser('~/memo.txt'))

Show us what you see, and we can work from there.  Can you also give us
the complete path where you see 'memo.txt' on your system?  Just right
click the file; it should show up somewhere on the file's property page.

Best of wishes to you!

More information about the Tutor mailing list