code: def _camel_killer(attr):
      
      try:
          attr = str(attr)
      except UnicodeEncodeError:
          attr = attr.encode("utf-8", "ignore")
  
      s1 = _first_cap_re.sub(r'\1_\2', attr)
      s2 = _all_cap_re.sub(r'\1_\2', s1)
      return re.sub('_+', '_', s2.casefold() if hasattr(s2, 'casefold')
                    else s2.lower())
docs: CamelKiller, qu'est-ce que c'est?
  
      Taken from http://stackoverflow.com/a/1176023/3244542