diff --git a/setup.py b/setup.py
index 412e072e5b675aa75fc7464ddda9536562fe998c..65c0a94a347c3a469a2ba13cf811539bfe93061a 100644
--- a/setup.py
+++ b/setup.py
@@ -194,9 +194,7 @@ def cython_extensions_and_necessity():
   cython_module_files = [os.path.join(PYTHON_STEM,
                                name.replace('.', '/') + '.pyx')
                   for name in CYTHON_EXTENSION_MODULE_NAMES]
-  config = os.environ['CONFIG']
-  if config is None:
-    config = 'opt'
+  config = os.environ.get('CONFIG', 'opt')
   prefix = 'libs/' + config + '/'
   if "darwin" in sys.platform:
     extra_objects = [prefix + 'libares.a',
diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
index 7db5de63b2ee53759a446cfd35b10fae31900e31..848b284f354944dcef45b540348f71ea77b360a8 100644
--- a/src/python/grpcio/commands.py
+++ b/src/python/grpcio/commands.py
@@ -267,9 +267,7 @@ class BuildExt(build_ext.build_ext):
 
     def build_extensions(self):
         if "darwin" in sys.platform:
-            config = os.environ['CONFIG']
-            if config is None:
-              config = 'opt'
+            config = os.environ.get('CONFIG', opt)
             target_path = os.path.abspath(
                 os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              '..', '..', '..', 'libs', config))