#test setup: >>> import os >>> os.environ['TESTING'] = '%TESTING1%' >>> os.environ['TESTING1'] = '%TESTING2%' >>> os.environ['TESTING2'] = 'Final\\Path' #test standard ntpath >>> import ntpath >>> ntpath.expanduser('~') 'C:\\Documents and Settings\\jcarlson' >>> ntpath.expanduser('~billy') '~billy' >>> ntpath.expanduser('~billy\\bob') '~billy\\bob' >>> ntpath.expanduser('~\\bob') 'C:\\Documents and Settings\\jcarlson\\bob' >>> ntpath.expanduser('~billy\\%TESTING%\\%TESTING1%\\%TESTING2%') '~billy\\%TESTING%\\%TESTING1%\\%TESTING2%' #test patched ntpath >>> import ntpath_patched >>> ntpath_patched.expanduser('~') 'C:Documents and Settings\\jcarlson' >>> ntpath_patched.expanduser('~billy') 'C:Documents and Settings\\billy' >>> ntpath_patched.expanduser('~billy\\bob') 'C:Documents and Settings\\billy\\bob' >>> ntpath_patched.expanduser('~\\bob') 'C:Documents and Settings\\jcarlson\\bob' >>> ntpath_patched.expanduser('~billy\\%TESTING%\\%TESTING1%\\%TESTING2%') 'C:Documents and Settings\\billy\\Final\\Path\\Final\\Path\\Final\\Path'