From a2d5eef39864834310c3da2674f9cc6baa2a2487 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 24 Oct 2019 14:26:19 +0200 Subject: [PATCH] Simplify access to os.environ The `if` can be removed by using `get()` with a default parameter to access `os.environ`. This also reduces the number of accesses to `os.environ`. --- kitty/constants.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kitty/constants.py b/kitty/constants.py index abdc3f9c9..60cde3731 100644 --- a/kitty/constants.py +++ b/kitty/constants.py @@ -49,9 +49,8 @@ def _get_config_dir(): locations.append(os.path.expanduser('~/.config')) if is_macos: locations.append(os.path.expanduser('~/Library/Preferences')) - if 'XDG_CONFIG_DIRS' in os.environ: - for loc in os.environ['XDG_CONFIG_DIRS'].split(os.pathsep): - locations.append(os.path.abspath(os.path.expanduser(loc))) + for loc in filter(None, os.environ.get('XDG_CONFIG_DIRS', '').split(os.pathsep)): + locations.append(os.path.abspath(os.path.expanduser(loc))) for loc in locations: if loc: q = os.path.join(loc, appname)