Commits

Aleš Erjavec committed 9f18a1e

Extended term name mangling to all python reserved keywords.

  • Participants
  • Parent commits fa3a9e4

Comments (0)

Files changed (1)

_bioinformatics/obiOntology.py

 import re
 import urllib2
 import warnings
+import keyword
 from collections import defaultdict
 from StringIO import StringIO
 
             ('def_', 'class_')
 
         """
-        if tag in ["def", "class", "in", "not"]:
+        if keyword.iskeyword(tag):
             return tag + "_"
         else:
             return tag
         """
         Reverse of `name_mangle`.
         """
-        if tag in ["def_", "class_", "in_", "not_"]:
+        if tag.endswith("_") and keyword.iskeyword(tag[:-1]):
             return tag[:-1]
         else:
             return tag