Fix for $HOME expansion on Mac OS X

os.path.expanduser does not seem to expand $HOME on Mac (only variations on ~), but os.path.expandvar does successfully expand $HOME (and any other variables in the path)

    Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin 
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> os.environ['HOME']
    '/Users/david'
    >>> os.path.expanduser('$HOME')
    '$HOME'
    >>> os.path.expanduser('$HOME/')
    '$HOME/'
    >>> os.path.expanduser('~')
    '/Users/david'
    >>> os.path.expanduser('~david')
    '/Users/david'
    >>> os.path.expandvars('$HOME')
    '/Users/david'