This if/else could be shortened to a single line, `self.cache_file = os.path.expanduser(cache_file or '')`. You can also remove the redundant `os.path.expanduser` on line 65 above.