Error when setting object Text Style

It might be the index approach that does not work in Python, in this line:

text_styles[style]

Maybe there is a GetTextStyle() method as replacement?