I would call `os.path.expanduser` regardless of the presence of the `~` because it will not affect the path if the `~` is not there. The `Exception` also seems unnecessary to me.