os.environ['HOME'] may not exists on Windows

Andrew Bennetts andrew at canonical.com
Mon Apr 11 14:35:30 BST 2005


On Mon, Apr 11, 2005 at 04:29:24PM +0300, Alexander Belchenko wrote:
> Hi!
> 
> I'm try to run bzr-0.0.3 and got error message:
> 
> Traceback (most recent call last):
[...]
>     trace_fname = os.path.join(os.environ['HOME'], '.bzr.log')
>   File "C:\Python24\lib\os.py", line 422, in __getitem__
>     return self.data[key.upper()]
> KeyError: 'HOME'

os.path.expanduser('~/.bzr.log') is a more portable way than
os.path.join(os.environ['HOME'], '.bzr.log').

-Andrew.





More information about the bazaar mailing list