if len(stack) > 0 and char == ',':
    return ';'
return char
text = "a,b,{'c','d','e','f'},g,h"
print(''.join(map(str, map(replace_comma_in_curly_brackets, text))))
Replace commas enclosed in curly braces