diff --git a/mkexp b/mkexp
index 652a902dd3eab74883e94ae0bf2c585a3e130e2e..64de09a6292ff208c4095c10a714bf4572d7ce7b 100755
--- a/mkexp
+++ b/mkexp
@@ -5,6 +5,8 @@
 # $Id$
 #
 
+from __future__ import print_function
+
 import copy
 import io
 import os
@@ -227,7 +229,7 @@ def format_vars(section, key, log, fmt):
 
     def replace(match):
         result = match.group(1)
-        if result.isidentifier():
+        if re.match(r'[_A-Za-z][_A-Za-z0-9]*$', result):
             log.add(result)
             return fmt%result
         return result