def camelcase_to_underscores(argument):
 result = u''
 prev_char_title = True
 for char in argument:
  if (char.istitle() and (not prev_char_title)):
   result += u'_'
  prev_char_title = char.istitle()
  if (not char.isspace()):
   result += char.lower()
 return result

def camelcase_to_underscores ( argument ) : result = u'' prev_char_title = True for char in argument : if ( char . istitle ( ) and ( not prev_char_title ) ) : result += u'_' prev_char_title = char . istitle ( ) if ( not char . isspace ( ) ) : result += char . lower ( ) return result
converts a camelcase param like thenewattribute to the equivalent python underscore variable like the_new_attribute .