

def cf_safe_name(name):
    import re
    if isinstance(name, str):
        if re.match('^[0-9_]', name):
            # Add a letter to the front
            name = "v_{}".format(name)
        return re.sub(r'[^_a-zA-Z0-9]', "_", name)



def isstr(s):
    try:
        return isinstance(s, basestring)
    except NameError:
        return isinstance(s, str)


def cf_safe_name(name):
    import re
    if isstr(name):
        if re.match('^[0-9_]', name):
            # Add a letter to the front
            name = "v_{}".format(name)
        return re.sub(r'[^_a-zA-Z0-9]', "_", name)

Fix cf_safe_name for python 2.7
Fix cf_safe_name for python 2.7

+ 
+ 
+ def isstr(s):
+     try:
+         return isinstance(s, basestring)
+     except NameError:
+         return isinstance(s, str)
  
  
  def cf_safe_name(name):
      import re
-     if isinstance(name, str):
+     if isstr(name):
          if re.match('^[0-9_]', name):
              # Add a letter to the front
              name = "v_{}".format(name)
          return re.sub(r'[^_a-zA-Z0-9]', "_", name)
  
Fix cf_safe_name for python 2.7
## Code Before:


def cf_safe_name(name):
    import re
    if isinstance(name, str):
        if re.match('^[0-9_]', name):
            # Add a letter to the front
            name = "v_{}".format(name)
        return re.sub(r'[^_a-zA-Z0-9]', "_", name)

## Instruction:
Fix cf_safe_name for python 2.7
## Code After:


def isstr(s):
    try:
        return isinstance(s, basestring)
    except NameError:
        return isinstance(s, str)


def cf_safe_name(name):
    import re
    if isstr(name):
        if re.match('^[0-9_]', name):
            # Add a letter to the front
            name = "v_{}".format(name)
        return re.sub(r'[^_a-zA-Z0-9]', "_", name)
